Revision 2016.05.03
Fork of MbedJSONValue by
Revision 7:174bc7a49aa2, committed 2016-05-03
- Comitter:
- joon874
- Date:
- Tue May 03 02:14:45 2016 +0000
- Parent:
- 6:f8bec9cada34
- Child:
- 8:2fe7e09ac67f
- Commit message:
- Revision 2016.05.03
Changed in this revision
MbedJSONValue.cpp | Show annotated file Show diff for this revision Revisions of this file |
MbedJSONValue.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MbedJSONValue.cpp Tue Apr 05 11:37:53 2016 +0000 +++ b/MbedJSONValue.cpp Tue May 03 02:14:45 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; } @@ -176,14 +190,14 @@ MbedJSONValue& MbedJSONValue::operator[](std::string k) { _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 //existing token 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 +209,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]); } @@ -206,7 +224,7 @@ MbedJSONValue& MbedJSONValue::operator[](std::string k) const { 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 @@ -214,7 +232,7 @@ printf(" comp "); 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]);
--- a/MbedJSONValue.h Tue Apr 05 11:37:53 2016 +0000 +++ b/MbedJSONValue.h Tue May 03 02:14:45 2016 +0000 @@ -34,7 +34,7 @@ #define NB_TOKEN 10 -//#define DEBUG +//#define DEBUG_MJSON /*!< Number maximum of MbedJSONValue in an array or an object */ @@ -45,6 +45,8 @@ #include <vector> + + typedef bool (*json_call_back)(void* param); bool default_json_cb(void* param);