MbedJSONValue Fork and Delete Array

Fork of MbedJSONValue by Midnight Cow

Revision:
8:fb820325a830
Parent:
7:62ce68f5a38c
--- a/MbedJSONValue.h	Tue May 03 02:31:26 2016 +0000
+++ b/MbedJSONValue.h	Tue May 31 10:30:22 2016 +0000
@@ -164,7 +164,6 @@
     * @param value the object created will be initialized with this string
     */
     MbedJSONValue(std::string const& value) : accessible(false), cb_action(default_json_cb), _type(TypeString), index_array(0), index_token(0) {
-//        printf("constructor:%s\r\n",value.c_str());
         token.resize(0);
         _value.asString = new std::string(value);
     }
@@ -455,7 +454,7 @@
 
 
 inline bool _parse_string(MbedJSONValue& out, input& in) {
-#ifdef DEBUG
+#ifdef DEBUG_MJSON
     printf("string detected\r\n");
 #endif
     out = MbedJSONValue(std::string(""));
@@ -492,7 +491,7 @@
 }
 
 inline bool _parse_array(MbedJSONValue& out, input& in) {
-#ifdef DEBUG
+#ifdef DEBUG_MJSON
     printf("array detected\r\n");
 #endif
     int i = 0;
@@ -509,7 +508,7 @@
 }
 
 inline bool _parse_object(MbedJSONValue& out, input& in) {
-#ifdef DEBUG
+#ifdef DEBUG_MJSON
     printf("object detected\r\n");
 #endif
     if (in.expect('}')) {
@@ -519,7 +518,7 @@
         MbedJSONValue key, val;
         if (in.expect('"') && _parse_string(key, in) && in.expect(':') && _parse(val, in)) {
             out[key.get<std::string>().c_str()] = val;
-#ifdef DEBUG
+#ifdef DEBUG_MJSON
             printf("key: %s \r\n", key.get<std::string>().c_str());
 #endif
         } else {
@@ -530,7 +529,7 @@
 }
 
 inline bool _parse_number(MbedJSONValue& out, input& in) {
-#ifdef DEBUG
+#ifdef DEBUG_MJSON
     printf("number detected\r\n");
 #endif
     std::string num_str;
@@ -572,6 +571,7 @@
         case '[':
             return _parse_array(out, in);
         case '{':
+            out._type = MbedJSONValue::TypeObject; 
             return _parse_object(out, in);
         default:
             if (('0' <= ch && ch <= '9') || ch == '-') {
@@ -593,6 +593,7 @@
 
 inline const char * parse(MbedJSONValue& out, const char * first, const char * last, std::string* err) {
     input in = input(first, last);
+
     if (! _parse(out, in) && err != NULL) {
         char buf[64];
         sprintf(buf, "syntax error at line %d near: ", in.line());