change code

Fork of MbedJSONValue_copy by Lawrence Lee

Revision:
7:62ce68f5a38c
Parent:
6:f8bec9cada34
Child:
8:fb820325a830
--- a/MbedJSONValue.cpp	Tue Apr 05 11:37:53 2016 +0000
+++ b/MbedJSONValue.cpp	Tue May 03 02:31:26 2016 +0000
@@ -107,15 +107,21 @@
 
 
 void MbedJSONValue::serialize(std::back_insert_iterator<std::string> oi) {
+#ifdef DEBUG_MJSON    
     printf("SP:%X   _type=%d, index=%d\r\n",__current_sp(),_type, index_token);
+#endif    
 
     switch (_type) {
         case TypeString:
+#ifdef DEBUG_MJSON            
         printf("typestring\r\n");
+#endif        
             serialize_str(*_value.asString, oi);
             break;
         case TypeArray: {
+#ifdef DEBUG_MJSON                
         printf("typearray\r\n");
+#endif        
             *oi++ = '[';
             for (int i = 0; i < index_array; i++) {
                 if (i)
@@ -126,13 +132,19 @@
             break;
         }
         case TypeObject: {
+#ifdef DEBUG_MJSON                
             printf("typeObject\r\n");
+#endif            
             *oi++ = '{';
             for (int i = 0; i < index_token; i++) {
+#ifdef DEBUG_MJSON                    
                 printf("i=%d ",i);
+#endif                
                 if (i)
                     *oi++ = ',';
+#ifdef DEBUG_MJSON                        
                 printf("token_name[%d]=%s\r\n",i,token_name[i]->c_str());
+#endif                
                 serialize_str(*(token_name[i]), oi);
                 *oi++ = ':';
                 (*(token[i])).serialize(oi);
@@ -141,7 +153,9 @@
             break;
         }
         default:
+#ifdef DEBUG_MJSON            
         printf("default\r\n");
+#endif        
             copy(to_str(), oi);
             break;
     }
@@ -177,6 +191,7 @@
     _type = TypeObject;
     for (int i = 0; i < index_token; i++) {
 #ifdef DEBUG
+#ifdef DEBUG_MJSON
         printf("k: %s\r\n", k.c_str());
         printf("str: %s\r\n", token_name[i]->c_str());
 #endif
@@ -184,6 +199,7 @@
 
         if (!strcmp(k.c_str(), token_name[i]->c_str())) {
 #ifdef DEBUG
+#ifdef DEBUG_MJSON
             printf("token found: %d\r\n", i);
 #endif
             return *(token[i]);
@@ -195,10 +211,14 @@
     //non existing token
     //token_name[index_token] = new std::string(k);
     token_name.push_back(new std::string(k));
+#ifdef DEBUG_MJSON        
     printf("New token_name[%d]=%X, %s\r\n", index_token, token_name[index_token], token_name[index_token]->c_str());
+#endif    
     //token[index_token] = new MbedJSONValue();
     token.push_back(new MbedJSONValue());
+#ifdef DEBUG_MJSON        
     printf("New token[%d]=%X, %d\r\n", index_token, token[index_token], token[index_token]->getType());
+#endif    
     index_token++;
     return *(token[index_token - 1]);
 }
@@ -207,6 +227,7 @@
 {
     for (int i = 0; i < index_token; i++) {
 #ifdef DEBUG
+#ifdef DEBUG_MJSON
         printf("k: %s\r\n", k.c_str());
         //printf("str: %s\r\n", token_name[i]->c_str());
 #endif
@@ -215,6 +236,7 @@
         printf("[%s]\r\n", token_name[i]->c_str());
         if (!strcmp(k.c_str(), token_name[i]->c_str())) {
 #ifdef DEBUG
+#ifdef DEBUG_MJSON
             printf("token found: %d\r\n", i);
 #endif
             return *(token[i]);