1. Create a new osrfListExtract function, which removes an item
[OpenSRF.git] / src / libopensrf / osrf_json_object.c
index 1eddd9c..75785d7 100644 (file)
@@ -352,7 +352,7 @@ static void add_json_to_buffer( const jsonObject* obj,
                        while( (item = osrfHashIteratorNext(itr)) ) {
                                if(i++ > 0) OSRF_BUFFER_ADD_CHAR(buf, ',');
                                OSRF_BUFFER_ADD_CHAR(buf, '"');
-                buffer_append_utf8(buf, osrfHashIteratorKey(itr));
+                               buffer_append_utf8(buf, osrfHashIteratorKey(itr));
                                OSRF_BUFFER_ADD(buf, "\":");
                                add_json_to_buffer( item, buf, do_classname, second_pass );
                        }
@@ -440,6 +440,14 @@ unsigned long jsonObjectRemoveIndex(jsonObject* dest, unsigned long index) {
 }
 
 
+jsonObject* jsonObjectExtractIndex(jsonObject* dest, unsigned long index) {
+       if( dest && dest->type == JSON_ARRAY ) {
+               return osrfListExtract(dest->value.l, index);
+       } else
+               return NULL;
+}
+
+
 unsigned long jsonObjectRemoveKey( jsonObject* dest, const char* key) {
        if( dest && key && dest->type == JSON_HASH ) {
                osrfHashRemove(dest->value.h, key);