GRASS 8 Programmer's Manual 8.5.0(2026)-8d6ceba290
Loading...
Searching...
No Matches
gjson.c
Go to the documentation of this file.
1/*!
2 \file lib/external/parson/gjson.c
3
4 \brief GRASS JSON Library
5
6 \since 8.5
7*/
8
9/*****************************************************************************
10 *
11 * MODULE: GRASS json output interface
12 *
13 * AUTHOR: Nishant Bansal (nishant.bansal.282003@gmail.com)
14 *
15 * PURPOSE: parson library function wrapper
16 * part of the gjson library
17 *
18 * COPYRIGHT: (C) 2024 by the GRASS Development Team
19 *
20 * This program is free software under the GNU General Public
21 * License (>=v2). Read the file COPYING that comes with GRASS
22 * for details.
23 *
24 *****************************************************************************/
25
26#include "gjson.h"
27#include "parson.h"
28
29/// \since version 8.5
30typedef struct json_object_t G_json_object_t;
31/// \since version 8.5
32typedef struct json_array_t G_json_array_t;
33/// \since version 8.5
34typedef struct json_value_t G_json_value_t;
35
36/* *************************************************************** */
37/* ***** WRAPPER FOR PARSON FUNCTIONS USED IN GRASS ************** */
38/* *************************************************************** */
39
40/// \since version 8.5
45
46/// \since version 8.5
51
52/// \since version 8.5
57
58/// \since version 8.5
63
64/// \since version 8.5
66{
67 return (G_JSON_Object *)json_object((const JSON_Value *)value);
68}
69
70/// \since version 8.5
72 const char *name)
73{
74 return (G_JSON_Object *)json_object_get_object((const JSON_Object *)object,
75 name);
76}
77
78/// \since version 8.5
80 const char *name)
81{
82 return (G_JSON_Array *)json_object_get_array((const JSON_Object *)object,
83 name);
84}
85
86/// \since version 8.5
88 const char *name)
89{
90 return (G_JSON_Value *)json_object_get_value((const JSON_Object *)object,
91 name);
92}
93
94/// \since version 8.5
95const char *G_json_object_get_string(const G_JSON_Object *object,
96 const char *name)
97{
98 return json_object_get_string((const JSON_Object *)object, name);
99}
100
101/// \since version 8.5
102double G_json_object_get_number(const G_JSON_Object *object, const char *name)
103{
104 return json_object_get_number((const JSON_Object *)object, name);
105}
106
107/// \since version 8.5
108int G_json_object_get_boolean(const G_JSON_Object *object, const char *name)
109{
110 return json_object_get_boolean((const JSON_Object *)object, name);
111}
112
113/// \since version 8.5
119
120/// \since version 8.5
122 G_JSON_Value *value)
123{
124 return json_object_set_value((JSON_Object *)object, name,
125 (JSON_Value *)value);
126}
127
128/// \since version 8.5
130 const char *string)
131{
132 return json_object_set_string((JSON_Object *)object, name, string);
133}
134
135/// \since version 8.5
137 double number)
138{
139 return json_object_set_number((JSON_Object *)object, name, number);
140}
141
142/// \since version 8.5
144 int boolean)
145{
146 return json_object_set_boolean((JSON_Object *)object, name, boolean);
147}
148
149/// \since version 8.5
151{
152 return json_object_set_null((JSON_Object *)object, name);
153}
154
155/// \since version 8.5
157 const char *name, const char *string)
158{
159 return json_object_dotset_string((JSON_Object *)object, name, string);
160}
161
162/// \since version 8.5
163const char *G_json_object_dotget_string(G_JSON_Object *object, const char *name)
164{
165 return json_object_dotget_string((JSON_Object *)object, name);
166}
167
168/// \since version 8.5
170 const char *name, double number)
171{
172 return json_object_dotset_number((JSON_Object *)object, name, number);
173}
174
175/// \since version 8.5
177{
178 return json_object_dotget_number((JSON_Object *)object, name);
179}
180
181/// \since version 8.5
186
187/// \since version 8.5
189{
190 return (G_JSON_Array *)json_array((const JSON_Value *)value);
191}
192
193/// \since version 8.5
195{
196 return (G_JSON_Value *)json_array_get_value((const JSON_Array *)array,
197 index);
198}
199
200/// \since version 8.5
201const char *G_json_array_get_string(const G_JSON_Array *array, size_t index)
202{
203 return json_array_get_string((const JSON_Array *)array, index);
204}
205
206/// \since version 8.5
207double G_json_array_get_number(const G_JSON_Array *array, size_t index)
208{
209 return json_array_get_number((const JSON_Array *)array, index);
210}
211
212/// \since version 8.5
213int G_json_array_get_boolean(const G_JSON_Array *array, size_t index)
214{
215 return json_array_get_boolean((const JSON_Array *)array, index);
216}
217
218/// \since version 8.5
224
225/// \since version 8.5
227 const char *string)
228{
229 return json_array_append_string((JSON_Array *)array, string);
230}
231
232/// \since version 8.5
234{
235 return json_array_append_number((JSON_Array *)array, number);
236}
237
238/// \since version 8.5
240{
241 return json_array_append_boolean((JSON_Array *)array, boolean);
242}
243
244/// \since version 8.5
249
250/// \since version 8.5
255
256/// \since version 8.5
258{
259 return json_serialize_to_string_pretty((const JSON_Value *)value);
260}
261
262/// \since version 8.5
264{
265 return json_serialize_to_string((const JSON_Value *)value);
266}
267
268/// \since version 8.5
270{
272}
273
274/// \since version 8.5
276{
277 json_value_free((JSON_Value *)value);
278}
G_JSON_Object * G_json_object_get_object(const G_JSON_Object *object, const char *name)
Definition gjson.c:71
G_JSON_Status G_json_array_append_boolean(G_JSON_Array *array, int boolean)
Definition gjson.c:239
struct json_value_t G_json_value_t
Definition gjson.c:34
G_JSON_Status G_json_object_set_number(G_JSON_Object *object, const char *name, double number)
Definition gjson.c:136
G_JSON_Array * G_json_array(const G_JSON_Value *value)
Definition gjson.c:188
G_JSON_Status G_json_object_set_null(G_JSON_Object *object, const char *name)
Definition gjson.c:150
G_JSON_Status G_json_array_append_null(G_JSON_Array *array)
Definition gjson.c:245
G_JSON_Value * G_json_object_get_wrapping_value(const G_JSON_Object *object)
Definition gjson.c:114
G_JSON_Value * G_json_array_get_value(const G_JSON_Array *array, size_t index)
Definition gjson.c:194
void G_json_value_free(G_JSON_Value *value)
Definition gjson.c:275
G_JSON_Status G_json_object_dotset_null(G_JSON_Object *object, const char *name)
Definition gjson.c:182
G_JSON_Status G_json_object_set_value(G_JSON_Object *object, const char *name, G_JSON_Value *value)
Definition gjson.c:121
int G_json_object_get_boolean(const G_JSON_Object *object, const char *name)
Definition gjson.c:108
G_JSON_Status G_json_object_dotset_number(G_JSON_Object *object, const char *name, double number)
Definition gjson.c:169
G_JSON_Status G_json_object_dotset_string(G_JSON_Object *object, const char *name, const char *string)
Definition gjson.c:156
G_JSON_Status G_json_object_set_boolean(G_JSON_Object *object, const char *name, int boolean)
Definition gjson.c:143
G_JSON_Status G_json_array_append_number(G_JSON_Array *array, double number)
Definition gjson.c:233
void G_json_free_serialized_string(char *string)
Definition gjson.c:269
double G_json_array_get_number(const G_JSON_Array *array, size_t index)
Definition gjson.c:207
G_JSON_Array * G_json_object_get_array(const G_JSON_Object *object, const char *name)
Definition gjson.c:79
char * G_json_serialize_to_string(const G_JSON_Value *value)
Definition gjson.c:263
int G_json_array_get_boolean(const G_JSON_Array *array, size_t index)
Definition gjson.c:213
const char * G_json_array_get_string(const G_JSON_Array *array, size_t index)
Definition gjson.c:201
char * G_json_serialize_to_string_pretty(const G_JSON_Value *value)
Definition gjson.c:257
G_JSON_Value_Type G_json_value_get_type(const G_JSON_Value *value)
Definition gjson.c:53
double G_json_object_get_number(const G_JSON_Object *object, const char *name)
Definition gjson.c:102
double G_json_object_dotget_number(G_JSON_Object *object, const char *name)
Definition gjson.c:176
G_JSON_Status G_json_object_set_string(G_JSON_Object *object, const char *name, const char *string)
Definition gjson.c:129
G_JSON_Value * G_json_value_init_object(void)
Definition gjson.c:41
struct json_object_t G_json_object_t
Definition gjson.c:30
G_JSON_Object * G_json_value_get_object(const G_JSON_Value *value)
Definition gjson.c:59
G_JSON_Status G_json_array_append_string(G_JSON_Array *array, const char *string)
Definition gjson.c:226
G_JSON_Value * G_json_object_get_value(const G_JSON_Object *object, const char *name)
Definition gjson.c:87
G_JSON_Value * G_json_value_init_array(void)
Definition gjson.c:47
const char * G_json_object_dotget_string(G_JSON_Object *object, const char *name)
Definition gjson.c:163
G_JSON_Object * G_json_object(const G_JSON_Value *value)
Definition gjson.c:65
struct json_array_t G_json_array_t
Definition gjson.c:32
void G_json_set_float_serialization_format(const char *format)
Definition gjson.c:251
const char * G_json_object_get_string(const G_JSON_Object *object, const char *name)
Definition gjson.c:95
G_JSON_Status G_json_array_append_value(G_JSON_Array *array, G_JSON_Value *value)
Definition gjson.c:219
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
int G_JSON_Status
Definition gjson.h:26
int G_JSON_Value_Type
Definition gjson.h:23
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