GRASS 8 Programmer's Manual 8.6.0dev(2026)-c83afef6d3
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 * SPDX-FileCopyrightText: 2024 GRASS Development Team
19 * SPDX-License-Identifier: GPL-2.0-or-later
20 *
21 *****************************************************************************/
22
23#include "gjson.h"
24#include "parson.h"
25
26/// \since version 8.5
27typedef struct json_object_t G_json_object_t;
28/// \since version 8.5
29typedef struct json_array_t G_json_array_t;
30/// \since version 8.5
31typedef struct json_value_t G_json_value_t;
32
33/* *************************************************************** */
34/* ***** WRAPPER FOR PARSON FUNCTIONS USED IN GRASS ************** */
35/* *************************************************************** */
36
37/// \since version 8.5
42
43/// \since version 8.5
48
49/// \since version 8.5
54
55/// \since version 8.5
60
61/// \since version 8.5
63{
64 return (G_JSON_Object *)json_object((const JSON_Value *)value);
65}
66
67/// \since version 8.5
69 const char *name)
70{
71 return (G_JSON_Object *)json_object_get_object((const JSON_Object *)object,
72 name);
73}
74
75/// \since version 8.5
77 const char *name)
78{
79 return (G_JSON_Array *)json_object_get_array((const JSON_Object *)object,
80 name);
81}
82
83/// \since version 8.5
85 const char *name)
86{
87 return (G_JSON_Value *)json_object_get_value((const JSON_Object *)object,
88 name);
89}
90
91/// \since version 8.5
92const char *G_json_object_get_string(const G_JSON_Object *object,
93 const char *name)
94{
95 return json_object_get_string((const JSON_Object *)object, name);
96}
97
98/// \since version 8.5
99double G_json_object_get_number(const G_JSON_Object *object, const char *name)
100{
101 return json_object_get_number((const JSON_Object *)object, name);
102}
103
104/// \since version 8.5
105int G_json_object_get_boolean(const G_JSON_Object *object, const char *name)
106{
107 return json_object_get_boolean((const JSON_Object *)object, name);
108}
109
110/// \since version 8.5
116
117/// \since version 8.5
119 G_JSON_Value *value)
120{
121 return json_object_set_value((JSON_Object *)object, name,
122 (JSON_Value *)value);
123}
124
125/// \since version 8.5
127 const char *string)
128{
129 return json_object_set_string((JSON_Object *)object, name, string);
130}
131
132/// \since version 8.5
134 double number)
135{
136 return json_object_set_number((JSON_Object *)object, name, number);
137}
138
139/// \since version 8.5
141 int boolean)
142{
143 return json_object_set_boolean((JSON_Object *)object, name, boolean);
144}
145
146/// \since version 8.5
148{
149 return json_object_set_null((JSON_Object *)object, name);
150}
151
152/// \since version 8.5
154 const char *name, const char *string)
155{
156 return json_object_dotset_string((JSON_Object *)object, name, string);
157}
158
159/// \since version 8.5
160const char *G_json_object_dotget_string(G_JSON_Object *object, const char *name)
161{
162 return json_object_dotget_string((JSON_Object *)object, name);
163}
164
165/// \since version 8.5
167 const char *name, double number)
168{
169 return json_object_dotset_number((JSON_Object *)object, name, number);
170}
171
172/// \since version 8.5
174{
175 return json_object_dotget_number((JSON_Object *)object, name);
176}
177
178/// \since version 8.5
183
184/// \since version 8.5
186{
187 return (G_JSON_Array *)json_array((const JSON_Value *)value);
188}
189
190/// \since version 8.5
192{
193 return (G_JSON_Value *)json_array_get_value((const JSON_Array *)array,
194 index);
195}
196
197/// \since version 8.5
198const char *G_json_array_get_string(const G_JSON_Array *array, size_t index)
199{
200 return json_array_get_string((const JSON_Array *)array, index);
201}
202
203/// \since version 8.5
204double G_json_array_get_number(const G_JSON_Array *array, size_t index)
205{
206 return json_array_get_number((const JSON_Array *)array, index);
207}
208
209/// \since version 8.5
210int G_json_array_get_boolean(const G_JSON_Array *array, size_t index)
211{
212 return json_array_get_boolean((const JSON_Array *)array, index);
213}
214
215/// \since version 8.5
221
222/// \since version 8.5
224 const char *string)
225{
226 return json_array_append_string((JSON_Array *)array, string);
227}
228
229/// \since version 8.5
231{
232 return json_array_append_number((JSON_Array *)array, number);
233}
234
235/// \since version 8.5
237{
238 return json_array_append_boolean((JSON_Array *)array, boolean);
239}
240
241/// \since version 8.5
246
247/// \since version 8.5
252
253/// \since version 8.5
255{
256 return json_serialize_to_string_pretty((const JSON_Value *)value);
257}
258
259/// \since version 8.5
261{
262 return json_serialize_to_string((const JSON_Value *)value);
263}
264
265/// \since version 8.5
267{
269}
270
271/// \since version 8.5
273{
274 json_value_free((JSON_Value *)value);
275}
G_JSON_Object * G_json_object_get_object(const G_JSON_Object *object, const char *name)
Definition gjson.c:68
G_JSON_Status G_json_array_append_boolean(G_JSON_Array *array, int boolean)
Definition gjson.c:236
struct json_value_t G_json_value_t
Definition gjson.c:31
G_JSON_Status G_json_object_set_number(G_JSON_Object *object, const char *name, double number)
Definition gjson.c:133
G_JSON_Array * G_json_array(const G_JSON_Value *value)
Definition gjson.c:185
G_JSON_Status G_json_object_set_null(G_JSON_Object *object, const char *name)
Definition gjson.c:147
G_JSON_Status G_json_array_append_null(G_JSON_Array *array)
Definition gjson.c:242
G_JSON_Value * G_json_object_get_wrapping_value(const G_JSON_Object *object)
Definition gjson.c:111
G_JSON_Value * G_json_array_get_value(const G_JSON_Array *array, size_t index)
Definition gjson.c:191
void G_json_value_free(G_JSON_Value *value)
Definition gjson.c:272
G_JSON_Status G_json_object_dotset_null(G_JSON_Object *object, const char *name)
Definition gjson.c:179
G_JSON_Status G_json_object_set_value(G_JSON_Object *object, const char *name, G_JSON_Value *value)
Definition gjson.c:118
int G_json_object_get_boolean(const G_JSON_Object *object, const char *name)
Definition gjson.c:105
G_JSON_Status G_json_object_dotset_number(G_JSON_Object *object, const char *name, double number)
Definition gjson.c:166
G_JSON_Status G_json_object_dotset_string(G_JSON_Object *object, const char *name, const char *string)
Definition gjson.c:153
G_JSON_Status G_json_object_set_boolean(G_JSON_Object *object, const char *name, int boolean)
Definition gjson.c:140
G_JSON_Status G_json_array_append_number(G_JSON_Array *array, double number)
Definition gjson.c:230
void G_json_free_serialized_string(char *string)
Definition gjson.c:266
double G_json_array_get_number(const G_JSON_Array *array, size_t index)
Definition gjson.c:204
G_JSON_Array * G_json_object_get_array(const G_JSON_Object *object, const char *name)
Definition gjson.c:76
char * G_json_serialize_to_string(const G_JSON_Value *value)
Definition gjson.c:260
int G_json_array_get_boolean(const G_JSON_Array *array, size_t index)
Definition gjson.c:210
const char * G_json_array_get_string(const G_JSON_Array *array, size_t index)
Definition gjson.c:198
char * G_json_serialize_to_string_pretty(const G_JSON_Value *value)
Definition gjson.c:254
G_JSON_Value_Type G_json_value_get_type(const G_JSON_Value *value)
Definition gjson.c:50
double G_json_object_get_number(const G_JSON_Object *object, const char *name)
Definition gjson.c:99
double G_json_object_dotget_number(G_JSON_Object *object, const char *name)
Definition gjson.c:173
G_JSON_Status G_json_object_set_string(G_JSON_Object *object, const char *name, const char *string)
Definition gjson.c:126
G_JSON_Value * G_json_value_init_object(void)
Definition gjson.c:38
struct json_object_t G_json_object_t
Definition gjson.c:27
G_JSON_Object * G_json_value_get_object(const G_JSON_Value *value)
Definition gjson.c:56
G_JSON_Status G_json_array_append_string(G_JSON_Array *array, const char *string)
Definition gjson.c:223
G_JSON_Value * G_json_object_get_value(const G_JSON_Object *object, const char *name)
Definition gjson.c:84
G_JSON_Value * G_json_value_init_array(void)
Definition gjson.c:44
const char * G_json_object_dotget_string(G_JSON_Object *object, const char *name)
Definition gjson.c:160
G_JSON_Object * G_json_object(const G_JSON_Value *value)
Definition gjson.c:62
struct json_array_t G_json_array_t
Definition gjson.c:29
void G_json_set_float_serialization_format(const char *format)
Definition gjson.c:248
const char * G_json_object_get_string(const G_JSON_Object *object, const char *name)
Definition gjson.c:92
G_JSON_Status G_json_array_append_value(G_JSON_Array *array, G_JSON_Value *value)
Definition gjson.c:216
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