GRASS GIS 8 Programmer's Manual  8.5.0dev(2025)-fbabf32052
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 
20 /* *************************************************************** */
21 /* ***** WRAPPER FOR PARSON FUNCTIONS USED IN GRASS ************** */
22 /* *************************************************************** */
23 
25 {
26  return json_value_init_object();
27 }
28 
30 {
31  return json_value_init_array();
32 }
33 
35 {
36  return json_value_get_object(value);
37 }
38 
40 {
41  return json_object(value);
42 }
44  const char *name)
45 {
46  return json_object_get_object(object, name);
47 }
48 JSON_Array *G_json_object_get_array(const JSON_Object *object, const char *name)
49 {
50  return json_object_get_array(object, name);
51 }
52 JSON_Value *G_json_object_get_value(const JSON_Object *object, const char *name)
53 {
54  return json_object_get_value(object, name);
55 }
56 const char *G_json_object_get_string(const JSON_Object *object,
57  const char *name)
58 {
59  return json_object_get_string(object, name);
60 }
61 double G_json_object_get_number(const JSON_Object *object, const char *name)
62 {
63  return json_object_get_number(object, name);
64 }
65 int G_json_object_get_boolean(const JSON_Object *object, const char *name)
66 {
67  return json_object_get_boolean(object, name);
68 }
70 {
71  return json_object_get_wrapping_value(object);
72 }
74  JSON_Value *value)
75 {
76  return json_object_set_value(object, name, value);
77 }
79  const char *string)
80 {
81  return json_object_set_string(object, name, string);
82 }
84  double number)
85 {
86  return json_object_set_number(object, name, number);
87 }
89  int boolean)
90 {
91  return json_object_set_boolean(object, name, boolean);
92 }
94 {
95  return json_object_set_null(object, name);
96 }
98 {
99  return json_array(value);
100 }
101 JSON_Value *G_json_array_get_value(const JSON_Array *array, size_t index)
102 {
103  return json_array_get_value(array, index);
104 }
105 const char *G_json_array_get_string(const JSON_Array *array, size_t index)
106 {
107  return json_array_get_string(array, index);
108 }
109 double G_json_array_get_number(const JSON_Array *array, size_t index)
110 {
111  return json_array_get_number(array, index);
112 }
113 int G_json_array_get_boolean(const JSON_Array *array, size_t index)
114 {
115  return json_array_get_boolean(array, index);
116 }
117 
119 {
120  return json_array_append_value(array, value);
121 }
122 
124 {
125  return json_array_append_string(array, string);
126 }
127 
129 {
130  return json_array_append_number(array, number);
131 }
132 
134 {
135  return json_array_append_boolean(array, boolean);
136 }
137 
139 {
140  return json_array_append_null(array);
141 }
142 
144 {
145  return json_serialize_to_string_pretty(value);
146 }
147 
149 {
151 }
153 {
154  json_value_free(value);
155 }
JSON_Status G_json_object_set_null(JSON_Object *object, const char *name)
Definition: gjson.c:93
JSON_Status G_json_array_append_boolean(JSON_Array *array, int boolean)
Definition: gjson.c:133
char * G_json_serialize_to_string_pretty(const JSON_Value *value)
Definition: gjson.c:143
void G_json_value_free(JSON_Value *value)
Definition: gjson.c:152
JSON_Status G_json_array_append_string(JSON_Array *array, const char *string)
Definition: gjson.c:123
JSON_Value * G_json_array_get_value(const JSON_Array *array, size_t index)
Definition: gjson.c:101
JSON_Status G_json_array_append_number(JSON_Array *array, double number)
Definition: gjson.c:128
JSON_Value * G_json_object_get_value(const JSON_Object *object, const char *name)
Definition: gjson.c:52
JSON_Object * G_json_value_get_object(const JSON_Value *value)
Definition: gjson.c:34
void G_json_free_serialized_string(char *string)
Definition: gjson.c:148
JSON_Status G_json_object_set_number(JSON_Object *object, const char *name, double number)
Definition: gjson.c:83
double G_json_object_get_number(const JSON_Object *object, const char *name)
Definition: gjson.c:61
const char * G_json_array_get_string(const JSON_Array *array, size_t index)
Definition: gjson.c:105
JSON_Status G_json_array_append_null(JSON_Array *array)
Definition: gjson.c:138
const char * G_json_object_get_string(const JSON_Object *object, const char *name)
Definition: gjson.c:56
JSON_Array * G_json_object_get_array(const JSON_Object *object, const char *name)
Definition: gjson.c:48
int G_json_object_get_boolean(const JSON_Object *object, const char *name)
Definition: gjson.c:65
JSON_Array * G_json_array(const JSON_Value *value)
Definition: gjson.c:97
JSON_Value * G_json_object_get_wrapping_value(const JSON_Object *object)
Definition: gjson.c:69
double G_json_array_get_number(const JSON_Array *array, size_t index)
Definition: gjson.c:109
JSON_Value * G_json_value_init_object(void)
Definition: gjson.c:24
JSON_Status G_json_object_set_value(JSON_Object *object, const char *name, JSON_Value *value)
Definition: gjson.c:73
JSON_Value * G_json_value_init_array(void)
Definition: gjson.c:29
JSON_Status G_json_object_set_string(JSON_Object *object, const char *name, const char *string)
Definition: gjson.c:78
int G_json_array_get_boolean(const JSON_Array *array, size_t index)
Definition: gjson.c:113
JSON_Object * G_json_object_get_object(const JSON_Object *object, const char *name)
Definition: gjson.c:43
JSON_Status G_json_object_set_boolean(JSON_Object *object, const char *name, int boolean)
Definition: gjson.c:88
JSON_Status G_json_array_append_value(JSON_Array *array, JSON_Value *value)
Definition: gjson.c:118
JSON_Object * G_json_object(const JSON_Value *value)
Definition: gjson.c:39
const char * name
Definition: named_colr.c:6
int json_object_get_boolean(const JSON_Object *object, const char *name)
Definition: parson.c:1656
JSON_Value * json_value_init_array(void)
Definition: parson.c:1897
JSON_Value * json_array_get_value(const JSON_Array *array, size_t index)
Definition: parson.c:1761
JSON_Status json_array_append_null(JSON_Array *array)
Definition: parson.c:2387
JSON_Object * json_value_get_object(const JSON_Value *value)
Definition: parson.c:1818
JSON_Status json_array_append_boolean(JSON_Array *array, int boolean)
Definition: parson.c:2374
JSON_Value * json_object_get_value(const JSON_Object *object, const char *name)
Definition: parson.c:1623
JSON_Status json_object_set_number(JSON_Object *object, const char *name, double number)
Definition: parson.c:2469
double json_array_get_number(const JSON_Array *array, size_t index)
Definition: parson.c:1779
const char * json_array_get_string(const JSON_Array *array, size_t index)
Definition: parson.c:1769
JSON_Status json_object_set_string(JSON_Object *object, const char *name, const char *string)
Definition: parson.c:2446
JSON_Status json_object_set_boolean(JSON_Object *object, const char *name, int boolean)
Definition: parson.c:2480
void json_free_serialized_string(char *string)
Definition: parson.c:2213
JSON_Object * json_object_get_object(const JSON_Object *object, const char *name)
Definition: parson.c:1646
JSON_Value * json_object_get_wrapping_value(const JSON_Object *object)
Definition: parson.c:1728
char * json_serialize_to_string_pretty(const JSON_Value *value)
Definition: parson.c:2192
JSON_Status json_array_append_value(JSON_Array *array, JSON_Value *value)
Definition: parson.c:2326
JSON_Object * json_object(const JSON_Value *value)
Definition: parson.c:2795
JSON_Value * json_value_init_object(void)
Definition: parson.c:1881
int json_array_get_boolean(const JSON_Array *array, size_t index)
Definition: parson.c:1794
JSON_Status json_object_set_value(JSON_Object *object, const char *name, JSON_Value *value)
Definition: parson.c:2400
void json_value_free(JSON_Value *value)
Definition: parson.c:1863
JSON_Status json_object_set_null(JSON_Object *object, const char *name)
Definition: parson.c:2491
JSON_Array * json_object_get_array(const JSON_Object *object, const char *name)
Definition: parson.c:1651
JSON_Status json_array_append_string(JSON_Array *array, const char *string)
Definition: parson.c:2334
const char * json_object_get_string(const JSON_Object *object, const char *name)
Definition: parson.c:1631
double json_object_get_number(const JSON_Object *object, const char *name)
Definition: parson.c:1641
JSON_Array * json_array(const JSON_Value *value)
Definition: parson.c:2800
JSON_Status json_array_append_number(JSON_Array *array, double number)
Definition: parson.c:2361
struct json_array_t JSON_Array
Definition: parson.h:46
int JSON_Status
Definition: parson.h:61
struct json_value_t JSON_Value
Definition: parson.h:47
struct json_object_t JSON_Object
Definition: parson.h:45