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
jo_add_int_array
void jo_add_int_array(JO parent, const char *name, const int *v, int n)
Definition: json_more_utils.c:300
jo_read_from_double_array
int jo_read_from_double_array(JO array, double *p, int n, double when_null)
Definition: json_more_utils.c:133
JO
struct json_object * JO
Definition: json_more_utils.h:7
p
struct @0 p
json_write
const char * json_write(JO jo)
Definition: json_more_utils.c:316
jo_read_int
int jo_read_int(JO parent, const char *name, int *p)
Definition: json_more_utils.c:249
jo_add_double
void jo_add_double(JO parent, const char *name, double v)
Definition: json_more_utils.c:308
json_to_double
int json_to_double(JO jo, double *ptr)
Definition: json_more_utils.c:236
jo_add_int
void jo_add_int(JO parent, const char *name, int v)
Definition: json_more_utils.c:304
json_to_int
int json_to_int(JO jo, int *ptr)
Definition: json_more_utils.c:218
jo_read_string
int jo_read_string(JO parent, const char *name, char *v, size_t max_len)
Definition: json_more_utils.c:280
jo_new_double_array
JO jo_new_double_array(const double *v, int n)
Definition: json_more_utils.c:201
jo_has_field
int jo_has_field(JO s, const char *name)
Definition: json_more_utils.c:117
jo_new_int_array
JO jo_new_int_array(const int *v, int n)
Definition: json_more_utils.c:209
jo_read_double_array
int jo_read_double_array(JO parent, const char *name, double *p, int n, double when_null)
Definition: json_more_utils.c:122
json_object.h
jo_double_or_null
JO jo_double_or_null(double d)
Definition: json_more_utils.c:196
json_tokener_parse_len
JO json_tokener_parse_len(const char *str, int len)
Definition: json_more_utils.c:101
json_parse
JO json_parse(const char *str)
Definition: json_more_utils.c:312
jo_read_int_array
int jo_read_int_array(JO parent, const char *name, int *p, int n, int when_null)
Definition: json_more_utils.c:169
jo_add_double_array
void jo_add_double_array(JO parent, const char *name, const double *v, int n)
Definition: json_more_utils.c:296
json_stream_skip
int json_stream_skip(FILE *)
Definition: json_more_utils.c:22
json_read_stream
JO json_read_stream(FILE *)
Definition: json_more_utils.c:48
json_object
Definition: json_object_private.h:21
jo_read_double
int jo_read_double(JO parent, const char *name, double *p)
Definition: json_more_utils.c:267
jo_add_string
void jo_add_string(JO parent, const char *name, const char *v)
Definition: json_more_utils.c:292


csm
Author(s): Andrea Censi
autogenerated on Wed Aug 17 2022 02:50:33