From df1ece4814c709e9f0bf6354c241a0cd7cb09507 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 3 Oct 2022 10:05:55 -0700 Subject: Added insertNull and appendNull to Bu::Json. Just helpers to make using json easier and easier. --- src/unstable/json.cpp | 10 ++++++++++ src/unstable/json.h | 2 ++ 2 files changed, 12 insertions(+) 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 ) return *pAr; } +Bu::Json &Bu::Json::insertNull( const Bu::String &sKey ) +{ + uDat.pObject->insert( sKey, new Json( Null ) ); +} + Bu::Json &Bu::Json::append( Bu::Json *pObj ) { uDat.pArray->append( pObj ); @@ -291,6 +296,11 @@ Bu::Json &Bu::Json::appendArray() return *pAr; } +Bu::Json &Bu::Json::appendNull() +{ + uDat.pArray->append( new Json( Null ) ); +} + void Bu::Json::parse( Bu::Stream &sInput ) { 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 Json &insert( const Bu::String &sKey, bool bValue ); Json &insertObject( const Bu::String &sKey ); Json &insertArray( const Bu::String &sKey ); + Json &insertNull( const Bu::String &sKey ); Json &append( Bu::Json *pObj ); Json &append( const Bu::String &sValue ); Json &append( const char *sValue ); @@ -91,6 +92,7 @@ namespace Bu Json &append( bool bValue ); Json &appendObject(); Json &appendArray(); + Json &appendNull(); void parse( Bu::Stream &sInput ); void parse( const Bu::String &sInput ); -- cgit v1.2.3