From feb899f0b0aaaf236577cacf16e4c3b25b292fe6 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 22 Aug 2017 11:58:37 -0700 Subject: Updated json. It needs a lot more work before it can be used to programattically build complex objects, but it's a great start. --- src/stable/fmt.h | 2 +- src/unstable/json.cpp | 7 ++++++- src/unstable/json.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/stable/fmt.h b/src/stable/fmt.h index 9ecaf80..a650062 100644 --- a/src/stable/fmt.h +++ b/src/stable/fmt.h @@ -59,7 +59,7 @@ namespace Bu static Fmt bin( unsigned int uWidth=0 ) { - return Fmt( uWidth, 1, Right, false, false, '0' ); + return Fmt( uWidth, 2, Right, false, false, '0' ); } static Fmt ptr( bool bCaps=true ) diff --git a/src/unstable/json.cpp b/src/unstable/json.cpp index f5a1696..d13f6e2 100644 --- a/src/unstable/json.cpp +++ b/src/unstable/json.cpp @@ -116,7 +116,7 @@ bool Bu::Json::isNull() const Bu::Json *Bu::Json::operator[]( const Bu::String &sKey ) const { - if( eType != Boolean ) + if( eType != Object ) throw Bu::ExceptionBase( "Object entry requested from non-object json object." ); @@ -159,6 +159,11 @@ Bu::Json::const_iterator Bu::Json::end() const return uDat.pArray->end(); } +void Bu::Json::insert( const Bu::String &sKey, Bu::Json *pObj ) +{ + uDat.pObject->insert( sKey, pObj ); +} + void Bu::Json::parse( Bu::Stream &sInput ) { reset(); diff --git a/src/unstable/json.h b/src/unstable/json.h index 76d96be..5a59b7e 100644 --- a/src/unstable/json.h +++ b/src/unstable/json.h @@ -51,6 +51,8 @@ namespace Bu iterator end(); const_iterator end() const; + void insert( const Bu::String &sKey, Bu::Json *pObj ); + void parse( Bu::Stream &sInput ); void parse( const Bu::String &sInput ); void reset(); -- cgit v1.2.3