aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2023-02-16 14:08:50 -0800
committerMike Buland <eichlan@xagasoft.com>2023-02-16 14:08:50 -0800
commit44409ec7257cb20ff091079eb55dc7a8d4049cf9 (patch)
treeb065862c46cb1a104c39c7ed6f27593137941ba5 /src
parentdf1ece4814c709e9f0bf6354c241a0cd7cb09507 (diff)
downloadlibbu++-44409ec7257cb20ff091079eb55dc7a8d4049cf9.tar.gz
libbu++-44409ec7257cb20ff091079eb55dc7a8d4049cf9.tar.bz2
libbu++-44409ec7257cb20ff091079eb55dc7a8d4049cf9.tar.xz
libbu++-44409ec7257cb20ff091079eb55dc7a8d4049cf9.zip
We now parse \u<hex> in json strings.
How we got away with it for this long is amazing.
Diffstat (limited to 'src')
-rw-r--r--src/unstable/json.cpp25
1 files changed, 24 insertions, 1 deletions
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 )
248Bu::Json &Bu::Json::insertNull( const Bu::String &sKey ) 248Bu::Json &Bu::Json::insertNull( const Bu::String &sKey )
249{ 249{
250 uDat.pObject->insert( sKey, new Json( Null ) ); 250 uDat.pObject->insert( sKey, new Json( Null ) );
251 return *this;
251} 252}
252 253
253Bu::Json &Bu::Json::append( Bu::Json *pObj ) 254Bu::Json &Bu::Json::append( Bu::Json *pObj )
@@ -299,6 +300,7 @@ Bu::Json &Bu::Json::appendArray()
299Bu::Json &Bu::Json::appendNull() 300Bu::Json &Bu::Json::appendNull()
300{ 301{
301 uDat.pArray->append( new Json( Null ) ); 302 uDat.pArray->append( new Json( Null ) );
303 return *this;
302} 304}
303 305
304void Bu::Json::parse( Bu::Stream &sInput ) 306void Bu::Json::parse( Bu::Stream &sInput )
@@ -595,7 +597,28 @@ void Bu::Json::parseString( Bu::Json::ParseState &ps, Bu::UtfString &sOut )
595 break; 597 break;
596 598
597 case 'u': 599 case 'u':
598 // Not implimented yet, followed by four hex diigts 600 {
601 char hex[5];
602 for( int j = 0; j < 4; j++ )
603 {
604 readChar( ps );
605 if( (ps.c >= '0' && ps.c <= '9') ||
606 (ps.c >= 'a' && ps.c <= 'f') ||
607 (ps.c >= 'A' && ps.c <= 'F') )
608 {
609 hex[j] = ps.c;
610 }
611 else
612 {
613 ps.error(
614 "Invalid json: Invalid \\u<hex> "
615 "escape sequence."
616 );
617 }
618 }
619 hex[4] = '\0';
620 sOut += (Bu::UtfChar)strtol( hex, NULL, 16 );
621 }
599 break; 622 break;
600 623
601 default: 624 default: