json_more_utils.h
Go to the documentation of this file.
1 #ifndef H_JSON_MORE_UTILS
2 #define H_JSON_MORE_UTILS
3 
4 #include <stdio.h>
5 #include "json_object.h"
6 
7 typedef struct json_object* JO;
8 
9 #define jo_new_double json_object_new_double
10 #define jo_new_int json_object_new_int
11 #define jo_new_array json_object_new_array
12 #define jo_new_string json_object_new_string
13 #define jo_new_null() 0
14 #define jo_add json_object_object_add
15 #define jo_del json_object_object_del
16 #define jo_free json_object_put
17 #define jo_get json_object_object_get
18 #define jo_new json_object_new_object
19 #define jo_array_add json_object_array_add
20 #define jo_array_get json_object_array_get_idx
21 #define jo_array_length json_object_array_length
22 #define jo_get_string json_object_get_string
23 
26 JO json_read_stream(FILE*);
27 
30 int json_stream_skip(FILE*);
31 
33 int jo_has_field(JO s, const char*name);
34 
35 JO jo_new_double_array(const double *v, int n);
36 JO jo_new_int_array (const int *v, int n);
37 
38 void jo_add_double (JO parent, const char*name, double v);
39 void jo_add_int (JO parent, const char*name, int v);
40 void jo_add_double_array (JO parent, const char*name, const double *v, int n);
41 void jo_add_int_array (JO parent, const char*name, const int *v, int n);
42 
43 void jo_add_string (JO parent, const char*name, const char*v);
44 
46 int jo_read_int (JO parent, const char*name, int*p) ;
48 int jo_read_double (JO parent, const char*name, double*p);
49 
50 /* Returns 0 if there isn't a field called "name", or it's not an array, or
51 its length is not at least "n". Else, it returns 1. */
52 int jo_read_double_array (JO parent, const char*name, double *p, int n, double when_null);
53 int jo_read_int_array (JO parent, const char*name, int *p, int n, int when_null);
54 int jo_read_string (JO parent, const char*name, char*v, size_t max_len);
55 
56 
57 /* Returns 0 if jo is not a double array, or its length is not n */
58 int jo_read_from_double_array (JO array, double *p, int n, double when_null);
59 
60 
61 int json_to_int(JO jo, int*ptr);
62 
65 int json_to_double(JO jo, double*ptr);
66 
67 
68 /* returns 0 if NAN */
69 JO jo_double_or_null(double d);
70 
71 /*JO find_object_with_name(JO root, const char*name);*/
72 JO json_tokener_parse_len(const char *str, int len);
73 JO json_parse(const char*str);
74 const char* json_write(JO jo);
75 #define jo_to_string json_write
76 
77 #endif
int jo_read_double_array(JO parent, const char *name, double *p, int n, double when_null)
int jo_read_string(JO parent, const char *name, char *v, size_t max_len)
void jo_add_double_array(JO parent, const char *name, const double *v, int n)
const char * json_write(JO jo)
JO json_parse(const char *str)
JO jo_new_int_array(const int *v, int n)
int jo_read_double(JO parent, const char *name, double *p)
JO json_read_stream(FILE *)
void jo_add_string(JO parent, const char *name, const char *v)
int jo_read_int_array(JO parent, const char *name, int *p, int n, int when_null)
struct @0 p
void jo_add_int_array(JO parent, const char *name, const int *v, int n)
int json_stream_skip(FILE *)
int jo_has_field(JO s, const char *name)
JO jo_double_or_null(double d)
JO json_tokener_parse_len(const char *str, int len)
JO jo_new_double_array(const double *v, int n)
void jo_add_double(JO parent, const char *name, double v)
int json_to_int(JO jo, int *ptr)
int jo_read_from_double_array(JO array, double *p, int n, double when_null)
void jo_add_int(JO parent, const char *name, int v)
int json_to_double(JO jo, double *ptr)
struct json_object * JO
int jo_read_int(JO parent, const char *name, int *p)


csm
Author(s): Andrea Censi
autogenerated on Tue May 11 2021 02:18:23