Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added template contructor for object

  • Loading branch information...
commit bec83626395d45286fd5673446ce7a27b93f636f 1 parent 0b2a8c0
@nestal nestal authored
Showing with 12 additions and 1 deletion.
  1. +12 −1 libgrive/src/protocol/Json.cc
View
13 libgrive/src/protocol/Json.cc
@@ -101,6 +101,17 @@ Json::Json( const bool& b ) :
BOOST_THROW_EXCEPTION( Error() << expt::ErrMsg( "cannot create json bool" ) ) ;
}
+template <>
+Json::Json( const Object& obj ) :
+ m_json( ::json_object_new_object() )
+{
+ if ( m_json == 0 )
+ BOOST_THROW_EXCEPTION( Error() << expt::ErrMsg( "cannot create json object" ) ) ;
+
+ for ( Object::const_iterator i = obj.begin() ; i != obj.end() ; ++i )
+ Add( i->first, i->second ) ;
+}
+
Json::Json( struct json_object *json, NotOwned ) :
m_json( json )
{
@@ -198,7 +209,7 @@ void Json::Add( const std::string& key, const Json& json )
{
assert( m_json != 0 ) ;
assert( json.m_json != 0 ) ;
-
+
::json_object_get( json.m_json ) ;
::json_object_object_add( m_json, key.c_str(), json.m_json ) ;
}
Please sign in to comment.
Something went wrong with that request. Please try again.