fix json parser core

This commit is contained in:
mwells 2014-09-10 06:58:18 -07:00
parent dc140e4224
commit d74df80f50
2 changed files with 10 additions and 3 deletions

View File

@ -241,7 +241,8 @@ JsonItem *Json::parseJsonStringIntoJsonItems ( char *json , long niceness ) {
// . otherwise, it was field value, so index it
// . TODO: later make field names compounded to
// better represent nesting?
else {
// . added 'else if (NAME){' fix for json=\"too small\"
else if ( NAME ) {
// make a new one in safebuf. our
// parent will be the array type item.
ji = addNewItem();
@ -264,6 +265,11 @@ JsonItem *Json::parseJsonStringIntoJsonItems ( char *json , long niceness ) {
// ok, this one is done
ji = NULL;
}
else {
log("json: fieldless name in json");
g_errno = EBADJSONPARSER;
return false;
}
// skip over the string
size = 0;
p = x;

View File

@ -1236,10 +1236,11 @@ int main2 ( int argc , char *argv[] ) {
}
/*
test json parser error with bad json
// test json parser error with bad json
Json jp;
char xxx[1024];
sprintf(xxx,"\"categories\":[\"shop\"");
//sprintf(xxx,"\"categories\":[\"shop\"");
sprintf(xxx,"\"too small\"");
jp.parseJsonStringIntoJsonItems(xxx,0);
JsonItem *ji = jp.getFirstItem();
for ( ; ji ; ji = ji->m_next ) {