mirror of
https://github.com/gigablast/open-source-search-engine.git
synced 2024-10-04 20:27:43 +03:00
fix json parser core
This commit is contained in:
parent
dc140e4224
commit
d74df80f50
8
Json.cpp
8
Json.cpp
@ -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;
|
||||
|
5
main.cpp
5
main.cpp
@ -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 ) {
|
||||
|
Loading…
Reference in New Issue
Block a user