From 44409ec7257cb20ff091079eb55dc7a8d4049cf9 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 16 Feb 2023 14:08:50 -0800 Subject: We now parse \u in json strings. How we got away with it for this long is amazing. --- src/unstable/json.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/unstable/json.cpp') diff --git a/src/unstable/json.cpp b/src/unstable/json.cpp index 0903499..e737f1e 100644 --- a/src/unstable/json.cpp +++ b/src/unstable/json.cpp @@ -248,6 +248,7 @@ Bu::Json &Bu::Json::insertArray( const Bu::String &sKey ) Bu::Json &Bu::Json::insertNull( const Bu::String &sKey ) { uDat.pObject->insert( sKey, new Json( Null ) ); + return *this; } Bu::Json &Bu::Json::append( Bu::Json *pObj ) @@ -299,6 +300,7 @@ Bu::Json &Bu::Json::appendArray() Bu::Json &Bu::Json::appendNull() { uDat.pArray->append( new Json( Null ) ); + return *this; } void Bu::Json::parse( Bu::Stream &sInput ) @@ -595,7 +597,28 @@ void Bu::Json::parseString( Bu::Json::ParseState &ps, Bu::UtfString &sOut ) break; case 'u': - // Not implimented yet, followed by four hex diigts + { + char hex[5]; + for( int j = 0; j < 4; j++ ) + { + readChar( ps ); + if( (ps.c >= '0' && ps.c <= '9') || + (ps.c >= 'a' && ps.c <= 'f') || + (ps.c >= 'A' && ps.c <= 'F') ) + { + hex[j] = ps.c; + } + else + { + ps.error( + "Invalid json: Invalid \\u " + "escape sequence." + ); + } + } + hex[4] = '\0'; + sOut += (Bu::UtfChar)strtol( hex, NULL, 16 ); + } break; default: -- cgit v1.2.3