Important Update:
- JSONparse: - Allow base entry to be Array or Object - Do not enforce escaping of '/' -> '\/' - Bug fix: properly encode string values in arrays
This commit is contained in:
@@ -352,11 +352,11 @@ bool CJSONparse::ReadFromBuffer( const char * BasePath )
|
|||||||
|
|
||||||
// Parse Root Object
|
// Parse Root Object
|
||||||
SkipWhiteSpace();
|
SkipWhiteSpace();
|
||||||
if (!ParseObject( BaseMember )) {
|
if (!ParseObject( BaseMember ) && !Error && !ParseArray( BaseMember )) {
|
||||||
if (!Error) {
|
if (!Error) {
|
||||||
Error = true;
|
Error = true;
|
||||||
CharNo += BufPos-Mark;
|
CharNo += BufPos-Mark;
|
||||||
sprintf( ErrorText, "First entry in file must be an Object on line %d:%d", LineNo, CharNo );
|
sprintf( ErrorText, "First entry in file must be an Object or Array on line %d:%d", LineNo, CharNo );
|
||||||
}
|
}
|
||||||
FreeBuffer();
|
FreeBuffer();
|
||||||
return false;
|
return false;
|
||||||
@@ -475,7 +475,7 @@ bool CJSONparse::ParseString( char ** Value, int &Len )
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Check for special characters
|
// Check for special characters
|
||||||
if ((EndMark = strpbrk( BufPos, "\"/\\\n\t\b\f\n\r" ))) {
|
if ((EndMark = strpbrk( BufPos, "\"\\\n\t\b\f\n\r" ))) { /*"\"/\\\n\t\b\f\n\r" (forward slash included)*/
|
||||||
BufPos = EndMark;
|
BufPos = EndMark;
|
||||||
} else if (RefillBuffer) {
|
} else if (RefillBuffer) {
|
||||||
FillBuffer();
|
FillBuffer();
|
||||||
@@ -816,7 +816,7 @@ bool CJSONparse::PrintString( char * String, int Len )
|
|||||||
{
|
{
|
||||||
// Scan for special chars
|
// Scan for special chars
|
||||||
Mark = BufPos;
|
Mark = BufPos;
|
||||||
while ((*BufPos >= 32) && (*BufPos <= 126) && (*BufPos != '\\') && (*BufPos != '/') && (*BufPos != '"'))
|
while ((*BufPos >= 32) && (*BufPos <= 126) && (*BufPos != '\\') && /*(*BufPos != '/') &&*/ (*BufPos != '"'))
|
||||||
BufPos++;
|
BufPos++;
|
||||||
|
|
||||||
// Print Portion
|
// Print Portion
|
||||||
@@ -1029,9 +1029,7 @@ bool CJSONparse::PrintArray( CDataMember * Array, const int Indent )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case jtString :
|
case jtString :
|
||||||
if ((Print( this, "\"", 1 ) < 0) ||
|
if (!PrintString( Member->Value, Member->Len ))
|
||||||
(Print( this, Member->Value, Member->Len ) < 0) ||
|
|
||||||
(Print( this, "\"", 1 ) < 0))
|
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user