GRASS 8 Programmer's Manual 8.6.0dev(2026)-6050dcdd58
Loading...
Searching...
No Matches
gjson.c
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * MODULE: GRASS json output interface
4 *
5 * AUTHOR: Nishant Bansal (nishant.bansal.282003@gmail.com)
6 *
7 * PURPOSE: parson library function wrapper
8 * part of the gjson library
9 *
10 * COPYRIGHT: (C) 2024 by the GRASS Development Team
11 *
12 * This program is free software under the GNU General Public
13 * License (>=v2). Read the file COPYING that comes with GRASS
14 * for details.
15 *
16 *****************************************************************************/
17
18#include "gjson.h"
19#include "parson.h"
20
21typedef struct json_object_t G_json_object_t;
22typedef struct json_array_t G_json_array_t;
23typedef struct json_value_t G_json_value_t;
24
25/* *************************************************************** */
26/* ***** WRAPPER FOR PARSON FUNCTIONS USED IN GRASS ************** */
27/* *************************************************************** */
28
33
38
43
48
50{
51 return (G_JSON_Object *)json_object((const JSON_Value *)value);
52}
53
55 const char *name)
56{
57 return (G_JSON_Object *)json_object_get_object((const JSON_Object *)object,
58 name);
59}
60
62 const char *name)
63{
64 return (G_JSON_Array *)json_object_get_array((const JSON_Object *)object,
65 name);
66}
67
69 const char *name)
70{
71 return (G_JSON_Value *)json_object_get_value((const JSON_Object *)object,
72 name);
73}
74
75const char *G_json_object_get_string(const G_JSON_Object *object,
76 const char *name)
77{
78 return json_object_get_string((const JSON_Object *)object, name);
79}
80
81double G_json_object_get_number(const G_JSON_Object *object, const char *name)
82{
83 return json_object_get_number((const JSON_Object *)object, name);
84}
85
86int G_json_object_get_boolean(const G_JSON_Object *object, const char *name)
87{
88 return json_object_get_boolean((const JSON_Object *)object, name);
89}
90
97 G_JSON_Value *value)
98{
99 return json_object_set_value((JSON_Object *)object, name,
100 (JSON_Value *)value);
101}
103 const char *string)
104{
105 return json_object_set_string((JSON_Object *)object, name, string);
106}
108 double number)
109{
110 return json_object_set_number((JSON_Object *)object, name, number);
111}
113 int boolean)
114{
115 return json_object_set_boolean((JSON_Object *)object, name, boolean);
116}
117
119{
120 return json_object_set_null((JSON_Object *)object, name);
121}
122
124 const char *name, const char *string)
125{
126 return json_object_dotset_string((JSON_Object *)object, name, string);
127}
128
129const char *G_json_object_dotget_string(G_JSON_Object *object, const char *name)
130{
131 return json_object_dotget_string((JSON_Object *)object, name);
132}
133
135 const char *name, double number)
136{
137 return json_object_dotset_number((JSON_Object *)object, name, number);
138}
139
141{
142 return json_object_dotget_number((JSON_Object *)object, name);
143}
144
149
151{
152 return (G_JSON_Array *)json_array((const JSON_Value *)value);
153}
154
156{
157 return (G_JSON_Value *)json_array_get_value((const JSON_Array *)array,
158 index);
159}
160
161const char *G_json_array_get_string(const G_JSON_Array *array, size_t index)
162{
163 return json_array_get_string((const JSON_Array *)array, index);
164}
165
166double G_json_array_get_number(const G_JSON_Array *array, size_t index)
167{
168 return json_array_get_number((const JSON_Array *)array, index);
169}
170
171int G_json_array_get_boolean(const G_JSON_Array *array, size_t index)
172{
173 return json_array_get_boolean((const JSON_Array *)array, index);
174}
175
181
183 const char *string)
184{
185 return json_array_append_string((JSON_Array *)array, string);
186}
187
189{
190 return json_array_append_number((JSON_Array *)array, number);
191}
192
194{
195 return json_array_append_boolean((JSON_Array *)array, boolean);
196}
197
202
207
209{
210 return json_serialize_to_string_pretty((const JSON_Value *)value);
211}
212
214{
215 return json_serialize_to_string((const JSON_Value *)value);
216}
217
219{
221}
222
224{
225 json_value_free((JSON_Value *)value);
226}
G_JSON_Object * G_json_object_get_object(const G_JSON_Object *object, const char *name)
Definition gjson.c:54
G_JSON_Status G_json_array_append_boolean(G_JSON_Array *array, int boolean)
Definition gjson.c:193
struct json_value_t G_json_value_t
Definition gjson.c:23
G_JSON_Status G_json_object_set_number(G_JSON_Object *object, const char *name, double number)
Definition gjson.c:107
G_JSON_Array * G_json_array(const G_JSON_Value *value)
Definition gjson.c:150
G_JSON_Status G_json_object_set_null(G_JSON_Object *object, const char *name)
Definition gjson.c:118
G_JSON_Status G_json_array_append_null(G_JSON_Array *array)
Definition gjson.c:198
G_JSON_Value * G_json_object_get_wrapping_value(const G_JSON_Object *object)
Definition gjson.c:91
G_JSON_Value * G_json_array_get_value(const G_JSON_Array *array, size_t index)
Definition gjson.c:155
void G_json_value_free(G_JSON_Value *value)
Definition gjson.c:223
G_JSON_Status G_json_object_dotset_null(G_JSON_Object *object, const char *name)
Definition gjson.c:145
G_JSON_Status G_json_object_set_value(G_JSON_Object *object, const char *name, G_JSON_Value *value)
Definition gjson.c:96
int G_json_object_get_boolean(const G_JSON_Object *object, const char *name)
Definition gjson.c:86
G_JSON_Status G_json_object_dotset_number(G_JSON_Object *object, const char *name, double number)
Definition gjson.c:134
G_JSON_Status G_json_object_dotset_string(G_JSON_Object *object, const char *name, const char *string)
Definition gjson.c:123
G_JSON_Status G_json_object_set_boolean(G_JSON_Object *object, const char *name, int boolean)
Definition gjson.c:112
G_JSON_Status G_json_array_append_number(G_JSON_Array *array, double number)
Definition gjson.c:188
void G_json_free_serialized_string(char *string)
Definition gjson.c:218
double G_json_array_get_number(const G_JSON_Array *array, size_t index)
Definition gjson.c:166
G_JSON_Array * G_json_object_get_array(const G_JSON_Object *object, const char *name)
Definition gjson.c:61
char * G_json_serialize_to_string(const G_JSON_Value *value)
Definition gjson.c:213
int G_json_array_get_boolean(const G_JSON_Array *array, size_t index)
Definition gjson.c:171
const char * G_json_array_get_string(const G_JSON_Array *array, size_t index)
Definition gjson.c:161
char * G_json_serialize_to_string_pretty(const G_JSON_Value *value)
Definition gjson.c:208
G_JSON_Value_Type G_json_value_get_type(const G_JSON_Value *value)
Definition gjson.c:39
double G_json_object_get_number(const G_JSON_Object *object, const char *name)
Definition gjson.c:81
double G_json_object_dotget_number(G_JSON_Object *object, const char *name)
Definition gjson.c:140
G_JSON_Status G_json_object_set_string(G_JSON_Object *object, const char *name, const char *string)
Definition gjson.c:102
G_JSON_Value * G_json_value_init_object(void)
Definition gjson.c:29
struct json_object_t G_json_object_t
Definition gjson.c:21
G_JSON_Object * G_json_value_get_object(const G_JSON_Value *value)
Definition gjson.c:44
G_JSON_Status G_json_array_append_string(G_JSON_Array *array, const char *string)
Definition gjson.c:182
G_JSON_Value * G_json_object_get_value(const G_JSON_Object *object, const char *name)
Definition gjson.c:68
G_JSON_Value * G_json_value_init_array(void)
Definition gjson.c:34
const char * G_json_object_dotget_string(G_JSON_Object *object, const char *name)
Definition gjson.c:129
G_JSON_Object * G_json_object(const G_JSON_Value *value)
Definition gjson.c:49
struct json_array_t G_json_array_t
Definition gjson.c:22
void G_json_set_float_serialization_format(const char *format)
Definition gjson.c:203
const char * G_json_object_get_string(const G_JSON_Object *object, const char *name)
Definition gjson.c:75
G_JSON_Status G_json_array_append_value(G_JSON_Array *array, G_JSON_Value *value)
Definition gjson.c:176
struct G_json_array_t G_JSON_Array
Definition gjson.h:11
struct G_json_object_t G_JSON_Object
Definition gjson.h:10
struct G_json_value_t G_JSON_Value
Definition gjson.h:12
const char * name
Definition named_colr.c:6
JSON_Status json_object_dotset_string(JSON_Object *object, const char *name, const char *string)
Definition parson.c:2559
int json_object_get_boolean(const JSON_Object *object, const char *name)
Definition parson.c:1660
JSON_Status json_array_append_null(JSON_Array *array)
Definition parson.c:2391
JSON_Value * json_array_get_value(const JSON_Array *array, size_t index)
Definition parson.c:1765
const char * json_array_get_string(const JSON_Array *array, size_t index)
Definition parson.c:1773
JSON_Status json_array_append_boolean(JSON_Array *array, int boolean)
Definition parson.c:2378
const char * json_object_dotget_string(const JSON_Object *object, const char *name)
Definition parson.c:1677
JSON_Status json_object_dotset_null(JSON_Object *object, const char *name)
Definition parson.c:2616
JSON_Status json_object_set_number(JSON_Object *object, const char *name, double number)
Definition parson.c:2473
JSON_Object * json_object_get_object(const JSON_Object *object, const char *name)
Definition parson.c:1650
void json_set_float_serialization_format(const char *format)
Definition parson.c:2841
double json_array_get_number(const JSON_Array *array, size_t index)
Definition parson.c:1783
JSON_Status json_object_set_string(JSON_Object *object, const char *name, const char *string)
Definition parson.c:2450
JSON_Status json_object_set_boolean(JSON_Object *object, const char *name, int boolean)
Definition parson.c:2484
void json_free_serialized_string(char *string)
Definition parson.c:2217
JSON_Value * json_value_init_array(void)
Definition parson.c:1901
JSON_Value * json_object_get_wrapping_value(const JSON_Object *object)
Definition parson.c:1732
JSON_Status json_array_append_value(JSON_Array *array, JSON_Value *value)
Definition parson.c:2330
JSON_Array * json_array(const JSON_Value *value)
Definition parson.c:2804
JSON_Array * json_object_get_array(const JSON_Object *object, const char *name)
Definition parson.c:1655
JSON_Value * json_object_get_value(const JSON_Object *object, const char *name)
Definition parson.c:1627
const char * json_object_get_string(const JSON_Object *object, const char *name)
Definition parson.c:1635
int json_array_get_boolean(const JSON_Array *array, size_t index)
Definition parson.c:1798
char * json_serialize_to_string(const JSON_Value *value)
Definition parson.c:2128
JSON_Status json_object_set_value(JSON_Object *object, const char *name, JSON_Value *value)
Definition parson.c:2404
void json_value_free(JSON_Value *value)
Definition parson.c:1867
JSON_Status json_object_set_null(JSON_Object *object, const char *name)
Definition parson.c:2495
JSON_Status json_array_append_string(JSON_Array *array, const char *string)
Definition parson.c:2338
double json_object_get_number(const JSON_Object *object, const char *name)
Definition parson.c:1645
double json_object_dotget_number(const JSON_Object *object, const char *name)
Definition parson.c:1689
JSON_Value_Type json_value_get_type(const JSON_Value *value)
Definition parson.c:1817
JSON_Object * json_value_get_object(const JSON_Value *value)
Definition parson.c:1822
JSON_Object * json_object(const JSON_Value *value)
Definition parson.c:2799
JSON_Value * json_value_init_object(void)
Definition parson.c:1885
char * json_serialize_to_string_pretty(const JSON_Value *value)
Definition parson.c:2196
JSON_Status json_object_dotset_number(JSON_Object *object, const char *name, double number)
Definition parson.c:2588
JSON_Status json_array_append_number(JSON_Array *array, double number)
Definition parson.c:2365
struct json_array_t JSON_Array
Definition parson.h:46
struct json_value_t JSON_Value
Definition parson.h:47
struct json_object_t JSON_Object
Definition parson.h:45