void VJSONArrayReader::_Parse(const VString &inJSONString) { if(inJSONString.IsEmpty()) { fLastParseError = VE_MALFORMED_JSON_DESCRIPTION; } else { VJSONImporter jsonImport(inJSONString); VString theStr; bool withquotes; VJSONImporter::JsonToken token = VJSONImporter::jsonNone; do { token = jsonImport.GetNextJSONToken(theStr, &withquotes); } while(token != VJSONImporter::jsonBeginArray && token != VJSONImporter::jsonNone); if(token == VJSONImporter::jsonBeginArray) { while (token != VJSONImporter::jsonEndArray && token != VJSONImporter::jsonNone && fLastParseError == VE_OK) { token = jsonImport.GetNextJSONToken(theStr, &withquotes); // Nested arrays are just ignored if (token == VJSONImporter::jsonBeginArray) { sLONG count = 1; while(count > 0 && token != VJSONImporter::jsonNone) { token = jsonImport.GetNextJSONToken(); if(token == VJSONImporter::jsonEndArray) --count; else if(token == VJSONImporter::jsonBeginArray) ++count; } if(count == 0 && token == VJSONImporter::jsonEndArray) token = jsonImport.GetNextJSONToken(theStr, &withquotes); else fLastParseError = VE_MALFORMED_JSON_DESCRIPTION; } if(fLastParseError == VE_OK && token == VJSONImporter::jsonString) { fValues.push_back(theStr); } }; if(token != VJSONImporter::jsonEndArray && fLastParseError == VE_OK) fLastParseError = VE_MALFORMED_JSON_DESCRIPTION; } else { fLastParseError = VE_MALFORMED_JSON_DESCRIPTION; } } if(fLastParseError != VE_OK) fValues.clear(); fVectorSize = (sLONG) fValues.size(); }
VError VValueBag::FromJSONString(const VString& inJSONString, JSONOption inModifier) { VJSONImporter jsonImport(inJSONString); return jsonImport.JSONObjectToBag(*this); }