json_more_utils.h
Go to the documentation of this file.
00001 #ifndef H_JSON_MORE_UTILS
00002 #define H_JSON_MORE_UTILS
00003 
00004 #include <stdio.h>
00005 #include "json_object.h"
00006 
00007 typedef struct json_object* JO;
00008 
00009 #define jo_new_double json_object_new_double 
00010 #define jo_new_int    json_object_new_int
00011 #define jo_new_array  json_object_new_array
00012 #define jo_new_string json_object_new_string
00013 #define jo_new_null()   0
00014 #define jo_add        json_object_object_add
00015 #define jo_del        json_object_object_del
00016 #define jo_free       json_object_put
00017 #define jo_get        json_object_object_get
00018 #define jo_new        json_object_new_object
00019 #define jo_array_add  json_object_array_add
00020 #define jo_array_get  json_object_array_get_idx
00021 #define jo_array_length json_object_array_length
00022 #define jo_get_string json_object_get_string 
00023 
00026 JO json_read_stream(FILE*);
00027 
00030 int json_stream_skip(FILE*);
00031 
00033 int jo_has_field(JO s, const char*name);
00034 
00035 JO jo_new_double_array(const double *v, int n);
00036 JO jo_new_int_array   (const int    *v, int n);
00037 
00038 void jo_add_double       (JO parent, const char*name, double v);
00039 void jo_add_int          (JO parent, const char*name, int    v);
00040 void jo_add_double_array (JO parent, const char*name, const double *v, int n);
00041 void jo_add_int_array    (JO parent, const char*name, const int    *v, int n);
00042 
00043 void jo_add_string       (JO parent, const char*name, const char*v);
00044 
00046 int jo_read_int          (JO parent, const char*name, int*p) ;
00048 int jo_read_double       (JO parent, const char*name, double*p);
00049 
00050 /* Returns 0 if there isn't a field called "name", or it's not an array, or 
00051 its length is not at least "n". Else, it returns 1. */
00052 int jo_read_double_array (JO parent, const char*name, double *p, int n, double when_null);
00053 int jo_read_int_array    (JO parent, const char*name, int    *p, int n, int    when_null);
00054 int jo_read_string       (JO parent, const char*name, char*v, size_t max_len);
00055 
00056 
00057 /* Returns 0 if jo is not a double array, or its length is not n */
00058 int jo_read_from_double_array (JO array, double *p, int n, double when_null);
00059 
00060 
00061 int json_to_int(JO jo, int*ptr);
00062 
00065 int json_to_double(JO jo, double*ptr);
00066 
00067         
00068 /* returns 0 if NAN */
00069 JO jo_double_or_null(double d);
00070 
00071 /*JO find_object_with_name(JO root, const char*name);*/
00072 JO json_tokener_parse_len(const char *str, int len);
00073 JO json_parse(const char*str);
00074 const char* json_write(JO jo);
00075 #define jo_to_string json_write
00076 
00077 #endif


csm
Author(s): Andrea Censi
autogenerated on Fri May 17 2019 02:28:33