X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=src%2Fjansson.h;h=c8a5a90eb48114a52fff623ee993999d70ba79fa;hb=e0a88d19d1f103c32bbaf4c20a83575413c4bf80;hp=b5cdddb9f421efa34ea761efe4a00d8c67ceae04;hpb=7728716759b73ee95b84c33a922bdc628dc7d2a9;p=jansson.git diff --git a/src/jansson.h b/src/jansson.h index b5cdddb..c8a5a90 100644 --- a/src/jansson.h +++ b/src/jansson.h @@ -9,7 +9,10 @@ #define JANSSON_H #include -#include + +#ifdef __cplusplus +extern "C" { +#endif /* types */ @@ -71,9 +74,12 @@ static inline void json_decref(json_t *json) /* getters, setters, manipulation */ +unsigned int json_object_size(const json_t *object); json_t *json_object_get(const json_t *object, const char *key); int json_object_set_new(json_t *object, const char *key, json_t *value); int json_object_del(json_t *object, const char *key); +int json_object_clear(json_t *object); +int json_object_update(json_t *object, json_t *other); void *json_object_iter(json_t *object); void *json_object_iter_next(json_t *object, void *iter); const char *json_object_iter_key(void *iter); @@ -89,6 +95,10 @@ unsigned int json_array_size(const json_t *array); json_t *json_array_get(const json_t *array, unsigned int index); int json_array_set_new(json_t *array, unsigned int index, json_t *value); int json_array_append_new(json_t *array, json_t *value); +int json_array_insert_new(json_t *array, unsigned int index, json_t *value); +int json_array_remove(json_t *array, unsigned int index); +int json_array_clear(json_t *array); +int json_array_extend(json_t *array, json_t *other); static inline int json_array_set(json_t *array, unsigned int index, json_t *value) @@ -102,12 +112,21 @@ int json_array_append(json_t *array, json_t *value) return json_array_append_new(array, json_incref(value)); } +static inline +int json_array_insert(json_t *array, unsigned int index, json_t *value) +{ + return json_array_insert_new(array, index, json_incref(value)); +} -const char *json_string_value(const json_t *json); -int json_integer_value(const json_t *json); -double json_real_value(const json_t *json); +const char *json_string_value(const json_t *string); +int json_integer_value(const json_t *integer); +double json_real_value(const json_t *real); double json_number_value(const json_t *json); +int json_string_set(const json_t *string, const char *value); +int json_integer_set(const json_t *integer, int value); +int json_real_set(const json_t *real, double value); + /* loading, printing */ @@ -123,9 +142,14 @@ json_t *json_loadf(FILE *input, json_error_t *error); json_t *json_load_file(const char *path, json_error_t *error); #define JSON_INDENT(n) (n & 0xFF) +#define JSON_COMPACT 0x100 char *json_dumps(const json_t *json, unsigned long flags); int json_dumpf(const json_t *json, FILE *output, unsigned long flags); int json_dump_file(const json_t *json, const char *path, unsigned long flags); +#ifdef __cplusplus +} +#endif + #endif