diff options
author | Mike Buland <mbuland@penny-arcade.com> | 2018-02-20 11:28:57 -0800 |
---|---|---|
committer | Mike Buland <mbuland@penny-arcade.com> | 2018-02-20 11:28:57 -0800 |
commit | e5f4c1fd2fb5402a637999f050fe64943ad2cfe9 (patch) | |
tree | 6e112cca00660676ef1819cb91cf8c2882317e56 /src/unstable | |
parent | 33bbff75b9102be69612fcecb9166fb79019845a (diff) | |
download | libbu++-e5f4c1fd2fb5402a637999f050fe64943ad2cfe9.tar.gz libbu++-e5f4c1fd2fb5402a637999f050fe64943ad2cfe9.tar.bz2 libbu++-e5f4c1fd2fb5402a637999f050fe64943ad2cfe9.tar.xz libbu++-e5f4c1fd2fb5402a637999f050fe64943ad2cfe9.zip |
Json parse fixes.
It didn't handle empty arrays or objects correctly.
Diffstat (limited to '')
-rw-r--r-- | src/unstable/json.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/unstable/json.cpp b/src/unstable/json.cpp index 273d5d3..adc2706 100644 --- a/src/unstable/json.cpp +++ b/src/unstable/json.cpp | |||
@@ -535,6 +535,14 @@ void Bu::Json::parseObject( char &c, Bu::Stream &sInput ) | |||
535 | uDat.pObject = new JsonHash(); | 535 | uDat.pObject = new JsonHash(); |
536 | 536 | ||
537 | next( "object" ); | 537 | next( "object" ); |
538 | |||
539 | // Check to see if it's an empty object. | ||
540 | if( c == '}' ) | ||
541 | { | ||
542 | next("object"); | ||
543 | return; | ||
544 | } | ||
545 | |||
538 | for(;;) | 546 | for(;;) |
539 | { | 547 | { |
540 | Bu::String sKey; | 548 | Bu::String sKey; |
@@ -572,6 +580,13 @@ void Bu::Json::parseArray( char &c, Bu::Stream &sInput ) | |||
572 | 580 | ||
573 | next("array"); | 581 | next("array"); |
574 | 582 | ||
583 | // Check to see if it's an empty array. | ||
584 | if( c == ']' ) | ||
585 | { | ||
586 | next("array"); | ||
587 | return; | ||
588 | } | ||
589 | |||
575 | for(;;) | 590 | for(;;) |
576 | { | 591 | { |
577 | uDat.pArray->append( new Json( c, sInput ) ); | 592 | uDat.pArray->append( new Json( c, sInput ) ); |