From e5f4c1fd2fb5402a637999f050fe64943ad2cfe9 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 20 Feb 2018 11:28:57 -0800 Subject: Json parse fixes. It didn't handle empty arrays or objects correctly. --- src/unstable/json.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 ) uDat.pObject = new JsonHash(); next( "object" ); + + // Check to see if it's an empty object. + if( c == '}' ) + { + next("object"); + return; + } + for(;;) { Bu::String sKey; @@ -572,6 +580,13 @@ void Bu::Json::parseArray( char &c, Bu::Stream &sInput ) next("array"); + // Check to see if it's an empty array. + if( c == ']' ) + { + next("array"); + return; + } + for(;;) { uDat.pArray->append( new Json( c, sInput ) ); -- cgit v1.2.3