version of jsonObjectGetKey. This is the first step in a plan to push
const-correctness on the OpenSRF stack when dealing with complex objects. The
hope is that this will increase the utility of compile-time checks in new
client code.
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1093
9efc2488-bf62-4759-914b-
345cdb29e865
* Retrieves the object at the given key
*/
jsonObject* jsonObjectGetKey( const jsonObject* obj, const char* key );
-
+const jsonObject* jsonObjectGetKeyConst( const jsonObject* obj, const char* key );
return osrfHashGet( obj->value.h, key);
}
+const jsonObject* jsonObjectGetKeyConst( const jsonObject* obj, const char* key ) {
+ if(!(obj && obj->type == JSON_HASH && obj->value.h && key)) return NULL;
+ return osrfHashGet( obj->value.h, key);
+}
+
char* jsonObjectToJSON( const jsonObject* obj ) {
jsonObject* obj2 = jsonObjectEncodeClass( (jsonObject*) obj);
char* json = jsonObjectToJSONRaw(obj2);