[Libjson-devel] JSONStream - use of single - double quote in the value
Brought to you by:
ninja9578
|
From: jebina e. <jeb...@ya...> - 2016-08-30 10:37:34
|
hi Johnathan Wallace,
Thanks for your amazing library.
When using JSONStream::operator << function, to parse the input json,if it contains the a \" in between the string say here is the example
{"name":"Test\"Quote"}it gives error saying its not proper json.
But the other hand, it parses correctly if its having two double quotes{"name":"Test\"Qu\"ote"}passes perfectly
Proposal: buffer = JSONWorker::RemoveWhiteSpaceAndComments(buffer, true); to be inserted in the function (JSONStream::parse) solves this issue.Any comments, and is there any patch planned for this issues
ThanksJake
void JSONStream::parse(void) json_throws(std::invalid_argument) { #ifdef JSON_SECURITY_MAX_STREAM_OBJECTS size_t objects = 0; #endif buffer = JSONWorker::RemoveWhiteSpaceAndComments(buffer, true); for(;;){ size_t pos = buffer.find_first_of(JSON_TEXT("{[")); if (json_likely(pos != json_string::npos)){ size_t end = (buffer[pos] == JSON_TEXT('[')) ? STREAM_FIND_NEXT_RELEVANT(JSON_TEXT(']'), buffer, pos + 1) : STREAM_FIND_NEXT_RELEVANT(JSON_TEXT('}'), buffer, pos + 1); if (end != json_string::npos){ #ifdef JSON_SECURITY_MAX_STREAM_OBJECTS if (++objects > JSON_SECURITY_MAX_STREAM_OBJECTS){ JSON_FAIL(JSON_TEXT("Maximum number of json objects for a stream at once has been reached")); if (err_call) err_call(getIdentifier()); state = false; return; } #endif START_MEM_SCOPE JSONNode temp(JSONWorker::parse(buffer.substr(pos, end - pos + 1))); #ifndef JSON_LIBRARY call(temp, getIdentifier()); #else call(&temp, getIdentifier()); #endif END_MEM_SCOPE json_string::iterator beginning = buffer.begin(); buffer.erase(beginning, beginning + end); continue; //parse(); //parse the next object too } #ifdef JSON_SAFE else { //verify that what's in there is at least valid so far #ifndef JSON_VALIDATE #error In order to use safe mode and streams, JSON_VALIDATE needs to be defined #endif json_auto<json_char> s; size_t len; s.set(JSONWorker::RemoveWhiteSpace(json_string(buffer.c_str() + pos), len, false)); if (!JSONValidator::isValidPartialRoot(s.ptr)){ if (err_call) err_call(getIdentifier()); state = false; } } #endif } break; }}
|