aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <mbuland@penny-arcade.com>2022-10-03 10:05:55 -0700
committerMike Buland <mbuland@penny-arcade.com>2022-10-03 10:05:55 -0700
commitdf1ece4814c709e9f0bf6354c241a0cd7cb09507 (patch)
treea8d8b275c31278ff25150698db508e9e29f405ea
parentfbcbfceb7fe95b974a4bbe46a1726034edde3946 (diff)
downloadlibbu++-df1ece4814c709e9f0bf6354c241a0cd7cb09507.tar.gz
libbu++-df1ece4814c709e9f0bf6354c241a0cd7cb09507.tar.bz2
libbu++-df1ece4814c709e9f0bf6354c241a0cd7cb09507.tar.xz
libbu++-df1ece4814c709e9f0bf6354c241a0cd7cb09507.zip
Added insertNull and appendNull to Bu::Json.
Just helpers to make using json easier and easier.
-rw-r--r--src/unstable/json.cpp10
-rw-r--r--src/unstable/json.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/src/unstable/json.cpp b/src/unstable/json.cpp
index 65bd195..0903499 100644
--- a/src/unstable/json.cpp
+++ b/src/unstable/json.cpp
@@ -245,6 +245,11 @@ Bu::Json &Bu::Json::insertArray( const Bu::String &sKey )
245 return *pAr; 245 return *pAr;
246} 246}
247 247
248Bu::Json &Bu::Json::insertNull( const Bu::String &sKey )
249{
250 uDat.pObject->insert( sKey, new Json( Null ) );
251}
252
248Bu::Json &Bu::Json::append( Bu::Json *pObj ) 253Bu::Json &Bu::Json::append( Bu::Json *pObj )
249{ 254{
250 uDat.pArray->append( pObj ); 255 uDat.pArray->append( pObj );
@@ -291,6 +296,11 @@ Bu::Json &Bu::Json::appendArray()
291 return *pAr; 296 return *pAr;
292} 297}
293 298
299Bu::Json &Bu::Json::appendNull()
300{
301 uDat.pArray->append( new Json( Null ) );
302}
303
294void Bu::Json::parse( Bu::Stream &sInput ) 304void Bu::Json::parse( Bu::Stream &sInput )
295{ 305{
296 reset(); 306 reset();
diff --git a/src/unstable/json.h b/src/unstable/json.h
index a973f74..14cb572 100644
--- a/src/unstable/json.h
+++ b/src/unstable/json.h
@@ -84,6 +84,7 @@ namespace Bu
84 Json &insert( const Bu::String &sKey, bool bValue ); 84 Json &insert( const Bu::String &sKey, bool bValue );
85 Json &insertObject( const Bu::String &sKey ); 85 Json &insertObject( const Bu::String &sKey );
86 Json &insertArray( const Bu::String &sKey ); 86 Json &insertArray( const Bu::String &sKey );
87 Json &insertNull( const Bu::String &sKey );
87 Json &append( Bu::Json *pObj ); 88 Json &append( Bu::Json *pObj );
88 Json &append( const Bu::String &sValue ); 89 Json &append( const Bu::String &sValue );
89 Json &append( const char *sValue ); 90 Json &append( const char *sValue );
@@ -91,6 +92,7 @@ namespace Bu
91 Json &append( bool bValue ); 92 Json &append( bool bValue );
92 Json &appendObject(); 93 Json &appendObject();
93 Json &appendArray(); 94 Json &appendArray();
95 Json &appendNull();
94 96
95 void parse( Bu::Stream &sInput ); 97 void parse( Bu::Stream &sInput );
96 void parse( const Bu::String &sInput ); 98 void parse( const Bu::String &sInput );