File indexing completed on 2026-01-08 10:17:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #pragma once
0027
0028 #if !defined(__JSON_GLIB_INSIDE__) && !defined(JSON_COMPILATION)
0029 #error "Only <json-glib/json-glib.h> can be included directly."
0030 #endif
0031
0032 #include <glib-object.h>
0033 #include <json-glib/json-version-macros.h>
0034
0035 G_BEGIN_DECLS
0036
0037
0038
0039
0040
0041
0042
0043 #define JSON_NODE_TYPE(node) (json_node_get_node_type ((node)))
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 #define JSON_NODE_HOLDS(node,t) (json_node_get_node_type ((node)) == (t))
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 #define JSON_NODE_HOLDS_VALUE(node) (JSON_NODE_HOLDS ((node), JSON_NODE_VALUE))
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 #define JSON_NODE_HOLDS_OBJECT(node) (JSON_NODE_HOLDS ((node), JSON_NODE_OBJECT))
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 #define JSON_NODE_HOLDS_ARRAY(node) (JSON_NODE_HOLDS ((node), JSON_NODE_ARRAY))
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 #define JSON_NODE_HOLDS_NULL(node) (JSON_NODE_HOLDS ((node), JSON_NODE_NULL))
0095
0096 #define JSON_TYPE_NODE (json_node_get_type ())
0097 #define JSON_TYPE_OBJECT (json_object_get_type ())
0098 #define JSON_TYPE_ARRAY (json_array_get_type ())
0099
0100 typedef struct _JsonNode JsonNode;
0101 typedef struct _JsonObject JsonObject;
0102 typedef struct _JsonArray JsonArray;
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113 typedef enum {
0114 JSON_NODE_OBJECT,
0115 JSON_NODE_ARRAY,
0116 JSON_NODE_VALUE,
0117 JSON_NODE_NULL
0118 } JsonNodeType;
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 typedef void (* JsonObjectForeach) (JsonObject *object,
0137 const gchar *member_name,
0138 JsonNode *member_node,
0139 gpointer user_data);
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157 typedef void (* JsonArrayForeach) (JsonArray *array,
0158 guint index_,
0159 JsonNode *element_node,
0160 gpointer user_data);
0161
0162
0163
0164
0165
0166 JSON_AVAILABLE_IN_1_0
0167 GType json_node_get_type (void) G_GNUC_CONST;
0168 JSON_AVAILABLE_IN_1_0
0169 JsonNode * json_node_new (JsonNodeType type);
0170
0171 JSON_AVAILABLE_IN_1_0
0172 JsonNode * json_node_alloc (void);
0173 JSON_AVAILABLE_IN_1_0
0174 JsonNode * json_node_init (JsonNode *node,
0175 JsonNodeType type);
0176 JSON_AVAILABLE_IN_1_0
0177 JsonNode * json_node_init_object (JsonNode *node,
0178 JsonObject *object);
0179 JSON_AVAILABLE_IN_1_0
0180 JsonNode * json_node_init_array (JsonNode *node,
0181 JsonArray *array);
0182 JSON_AVAILABLE_IN_1_0
0183 JsonNode * json_node_init_int (JsonNode *node,
0184 gint64 value);
0185 JSON_AVAILABLE_IN_1_0
0186 JsonNode * json_node_init_double (JsonNode *node,
0187 gdouble value);
0188 JSON_AVAILABLE_IN_1_0
0189 JsonNode * json_node_init_boolean (JsonNode *node,
0190 gboolean value);
0191 JSON_AVAILABLE_IN_1_0
0192 JsonNode * json_node_init_string (JsonNode *node,
0193 const char *value);
0194 JSON_AVAILABLE_IN_1_0
0195 JsonNode * json_node_init_null (JsonNode *node);
0196
0197 JSON_AVAILABLE_IN_1_0
0198 JsonNode * json_node_copy (JsonNode *node);
0199 JSON_AVAILABLE_IN_1_0
0200 void json_node_free (JsonNode *node);
0201
0202 JSON_AVAILABLE_IN_1_2
0203 JsonNode * json_node_ref (JsonNode *node);
0204 JSON_AVAILABLE_IN_1_2
0205 void json_node_unref (JsonNode *node);
0206
0207 JSON_AVAILABLE_IN_1_0
0208 JsonNodeType json_node_get_node_type (JsonNode *node);
0209 JSON_AVAILABLE_IN_1_0
0210 GType json_node_get_value_type (JsonNode *node);
0211 JSON_AVAILABLE_IN_1_0
0212 void json_node_set_parent (JsonNode *node,
0213 JsonNode *parent);
0214 JSON_AVAILABLE_IN_1_0
0215 JsonNode * json_node_get_parent (JsonNode *node);
0216 JSON_AVAILABLE_IN_1_0
0217 const gchar * json_node_type_name (JsonNode *node);
0218
0219 JSON_AVAILABLE_IN_1_0
0220 void json_node_set_object (JsonNode *node,
0221 JsonObject *object);
0222 JSON_AVAILABLE_IN_1_0
0223 void json_node_take_object (JsonNode *node,
0224 JsonObject *object);
0225 JSON_AVAILABLE_IN_1_0
0226 JsonObject * json_node_get_object (JsonNode *node);
0227 JSON_AVAILABLE_IN_1_0
0228 JsonObject * json_node_dup_object (JsonNode *node);
0229 JSON_AVAILABLE_IN_1_0
0230 void json_node_set_array (JsonNode *node,
0231 JsonArray *array);
0232 JSON_AVAILABLE_IN_1_0
0233 void json_node_take_array (JsonNode *node,
0234 JsonArray *array);
0235 JSON_AVAILABLE_IN_1_0
0236 JsonArray * json_node_get_array (JsonNode *node);
0237 JSON_AVAILABLE_IN_1_0
0238 JsonArray * json_node_dup_array (JsonNode *node);
0239 JSON_AVAILABLE_IN_1_0
0240 void json_node_set_value (JsonNode *node,
0241 const GValue *value);
0242 JSON_AVAILABLE_IN_1_0
0243 void json_node_get_value (JsonNode *node,
0244 GValue *value);
0245 JSON_AVAILABLE_IN_1_0
0246 void json_node_set_string (JsonNode *node,
0247 const gchar *value);
0248 JSON_AVAILABLE_IN_1_0
0249 const gchar * json_node_get_string (JsonNode *node);
0250 JSON_AVAILABLE_IN_1_0
0251 gchar * json_node_dup_string (JsonNode *node);
0252 JSON_AVAILABLE_IN_1_0
0253 void json_node_set_int (JsonNode *node,
0254 gint64 value);
0255 JSON_AVAILABLE_IN_1_0
0256 gint64 json_node_get_int (JsonNode *node);
0257 JSON_AVAILABLE_IN_1_0
0258 void json_node_set_double (JsonNode *node,
0259 gdouble value);
0260 JSON_AVAILABLE_IN_1_0
0261 gdouble json_node_get_double (JsonNode *node);
0262 JSON_AVAILABLE_IN_1_0
0263 void json_node_set_boolean (JsonNode *node,
0264 gboolean value);
0265 JSON_AVAILABLE_IN_1_0
0266 gboolean json_node_get_boolean (JsonNode *node);
0267 JSON_AVAILABLE_IN_1_0
0268 gboolean json_node_is_null (JsonNode *node);
0269
0270 JSON_AVAILABLE_IN_1_2
0271 void json_node_seal (JsonNode *node);
0272 JSON_AVAILABLE_IN_1_2
0273 gboolean json_node_is_immutable (JsonNode *node);
0274
0275 JSON_AVAILABLE_IN_1_2
0276 guint json_string_hash (gconstpointer key);
0277 JSON_AVAILABLE_IN_1_2
0278 gboolean json_string_equal (gconstpointer a,
0279 gconstpointer b);
0280 JSON_AVAILABLE_IN_1_2
0281 gint json_string_compare (gconstpointer a,
0282 gconstpointer b);
0283
0284 JSON_AVAILABLE_IN_1_2
0285 guint json_node_hash (gconstpointer key);
0286 JSON_AVAILABLE_IN_1_2
0287 gboolean json_node_equal (gconstpointer a,
0288 gconstpointer b);
0289
0290
0291
0292
0293 JSON_AVAILABLE_IN_1_0
0294 GType json_object_get_type (void) G_GNUC_CONST;
0295 JSON_AVAILABLE_IN_1_0
0296 JsonObject * json_object_new (void);
0297 JSON_AVAILABLE_IN_1_0
0298 JsonObject * json_object_ref (JsonObject *object);
0299 JSON_AVAILABLE_IN_1_0
0300 void json_object_unref (JsonObject *object);
0301
0302 JSON_DEPRECATED_IN_1_0_FOR(json_object_set_member)
0303 void json_object_add_member (JsonObject *object,
0304 const gchar *member_name,
0305 JsonNode *node);
0306
0307 JSON_AVAILABLE_IN_1_0
0308 void json_object_set_member (JsonObject *object,
0309 const gchar *member_name,
0310 JsonNode *node);
0311 JSON_AVAILABLE_IN_1_0
0312 void json_object_set_int_member (JsonObject *object,
0313 const gchar *member_name,
0314 gint64 value);
0315 JSON_AVAILABLE_IN_1_0
0316 void json_object_set_double_member (JsonObject *object,
0317 const gchar *member_name,
0318 gdouble value);
0319 JSON_AVAILABLE_IN_1_0
0320 void json_object_set_boolean_member (JsonObject *object,
0321 const gchar *member_name,
0322 gboolean value);
0323 JSON_AVAILABLE_IN_1_0
0324 void json_object_set_string_member (JsonObject *object,
0325 const gchar *member_name,
0326 const gchar *value);
0327 JSON_AVAILABLE_IN_1_0
0328 void json_object_set_null_member (JsonObject *object,
0329 const gchar *member_name);
0330 JSON_AVAILABLE_IN_1_0
0331 void json_object_set_array_member (JsonObject *object,
0332 const gchar *member_name,
0333 JsonArray *value);
0334 JSON_AVAILABLE_IN_1_0
0335 void json_object_set_object_member (JsonObject *object,
0336 const gchar *member_name,
0337 JsonObject *value);
0338 JSON_AVAILABLE_IN_1_0
0339 GList * json_object_get_members (JsonObject *object);
0340 JSON_AVAILABLE_IN_1_0
0341 JsonNode * json_object_get_member (JsonObject *object,
0342 const gchar *member_name);
0343 JSON_AVAILABLE_IN_1_0
0344 JsonNode * json_object_dup_member (JsonObject *object,
0345 const gchar *member_name);
0346 JSON_AVAILABLE_IN_1_0
0347 gint64 json_object_get_int_member (JsonObject *object,
0348 const gchar *member_name);
0349 JSON_AVAILABLE_IN_1_6
0350 gint64 json_object_get_int_member_with_default (JsonObject *object,
0351 const char *member_name,
0352 gint64 default_value);
0353 JSON_AVAILABLE_IN_1_0
0354 gdouble json_object_get_double_member (JsonObject *object,
0355 const gchar *member_name);
0356 JSON_AVAILABLE_IN_1_6
0357 double json_object_get_double_member_with_default (JsonObject *object,
0358 const char *member_name,
0359 double default_value);
0360 JSON_AVAILABLE_IN_1_0
0361 gboolean json_object_get_boolean_member (JsonObject *object,
0362 const gchar *member_name);
0363 JSON_AVAILABLE_IN_1_6
0364 gboolean json_object_get_boolean_member_with_default (JsonObject *object,
0365 const char *member_name,
0366 gboolean default_value);
0367 JSON_AVAILABLE_IN_1_0
0368 const gchar * json_object_get_string_member (JsonObject *object,
0369 const gchar *member_name);
0370 JSON_AVAILABLE_IN_1_6
0371 const char * json_object_get_string_member_with_default (JsonObject *object,
0372 const char *member_name,
0373 const char *default_value);
0374 JSON_AVAILABLE_IN_1_0
0375 gboolean json_object_get_null_member (JsonObject *object,
0376 const gchar *member_name);
0377 JSON_AVAILABLE_IN_1_0
0378 JsonArray * json_object_get_array_member (JsonObject *object,
0379 const gchar *member_name);
0380 JSON_AVAILABLE_IN_1_0
0381 JsonObject * json_object_get_object_member (JsonObject *object,
0382 const gchar *member_name);
0383 JSON_AVAILABLE_IN_1_0
0384 gboolean json_object_has_member (JsonObject *object,
0385 const gchar *member_name);
0386 JSON_AVAILABLE_IN_1_0
0387 void json_object_remove_member (JsonObject *object,
0388 const gchar *member_name);
0389 JSON_AVAILABLE_IN_1_0
0390 GList * json_object_get_values (JsonObject *object);
0391 JSON_AVAILABLE_IN_1_0
0392 guint json_object_get_size (JsonObject *object);
0393 JSON_AVAILABLE_IN_1_0
0394 void json_object_foreach_member (JsonObject *object,
0395 JsonObjectForeach func,
0396 gpointer data);
0397
0398 JSON_AVAILABLE_IN_1_2
0399 void json_object_seal (JsonObject *object);
0400 JSON_AVAILABLE_IN_1_2
0401 gboolean json_object_is_immutable (JsonObject *object);
0402
0403 JSON_AVAILABLE_IN_1_2
0404 guint json_object_hash (gconstpointer key);
0405 JSON_AVAILABLE_IN_1_2
0406 gboolean json_object_equal (gconstpointer a,
0407 gconstpointer b);
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425 typedef struct {
0426
0427 gpointer priv_pointer[6];
0428 int priv_int[2];
0429 gboolean priv_boolean[1];
0430 } JsonObjectIter;
0431
0432 JSON_AVAILABLE_IN_1_2
0433 void json_object_iter_init (JsonObjectIter *iter,
0434 JsonObject *object);
0435 JSON_AVAILABLE_IN_1_2
0436 gboolean json_object_iter_next (JsonObjectIter *iter,
0437 const gchar **member_name,
0438 JsonNode **member_node);
0439
0440 JSON_AVAILABLE_IN_1_6
0441 void json_object_iter_init_ordered (JsonObjectIter *iter,
0442 JsonObject *object);
0443 JSON_AVAILABLE_IN_1_6
0444 gboolean json_object_iter_next_ordered (JsonObjectIter *iter,
0445 const char **member_name,
0446 JsonNode **member_node);
0447
0448 JSON_AVAILABLE_IN_1_0
0449 GType json_array_get_type (void) G_GNUC_CONST;
0450 JSON_AVAILABLE_IN_1_0
0451 JsonArray * json_array_new (void);
0452 JSON_AVAILABLE_IN_1_0
0453 JsonArray * json_array_sized_new (guint n_elements);
0454 JSON_AVAILABLE_IN_1_0
0455 JsonArray * json_array_ref (JsonArray *array);
0456 JSON_AVAILABLE_IN_1_0
0457 void json_array_unref (JsonArray *array);
0458 JSON_AVAILABLE_IN_1_0
0459 void json_array_add_element (JsonArray *array,
0460 JsonNode *node);
0461 JSON_AVAILABLE_IN_1_0
0462 void json_array_add_int_element (JsonArray *array,
0463 gint64 value);
0464 JSON_AVAILABLE_IN_1_0
0465 void json_array_add_double_element (JsonArray *array,
0466 gdouble value);
0467 JSON_AVAILABLE_IN_1_0
0468 void json_array_add_boolean_element (JsonArray *array,
0469 gboolean value);
0470 JSON_AVAILABLE_IN_1_0
0471 void json_array_add_string_element (JsonArray *array,
0472 const gchar *value);
0473 JSON_AVAILABLE_IN_1_0
0474 void json_array_add_null_element (JsonArray *array);
0475 JSON_AVAILABLE_IN_1_0
0476 void json_array_add_array_element (JsonArray *array,
0477 JsonArray *value);
0478 JSON_AVAILABLE_IN_1_0
0479 void json_array_add_object_element (JsonArray *array,
0480 JsonObject *value);
0481 JSON_AVAILABLE_IN_1_0
0482 GList * json_array_get_elements (JsonArray *array);
0483 JSON_AVAILABLE_IN_1_0
0484 JsonNode * json_array_get_element (JsonArray *array,
0485 guint index_);
0486 JSON_AVAILABLE_IN_1_0
0487 gint64 json_array_get_int_element (JsonArray *array,
0488 guint index_);
0489 JSON_AVAILABLE_IN_1_0
0490 gdouble json_array_get_double_element (JsonArray *array,
0491 guint index_);
0492 JSON_AVAILABLE_IN_1_0
0493 gboolean json_array_get_boolean_element (JsonArray *array,
0494 guint index_);
0495 JSON_AVAILABLE_IN_1_0
0496 const gchar * json_array_get_string_element (JsonArray *array,
0497 guint index_);
0498 JSON_AVAILABLE_IN_1_0
0499 gboolean json_array_get_null_element (JsonArray *array,
0500 guint index_);
0501 JSON_AVAILABLE_IN_1_0
0502 JsonArray * json_array_get_array_element (JsonArray *array,
0503 guint index_);
0504 JSON_AVAILABLE_IN_1_0
0505 JsonObject * json_array_get_object_element (JsonArray *array,
0506 guint index_);
0507 JSON_AVAILABLE_IN_1_0
0508 JsonNode * json_array_dup_element (JsonArray *array,
0509 guint index_);
0510 JSON_AVAILABLE_IN_1_0
0511 void json_array_remove_element (JsonArray *array,
0512 guint index_);
0513 JSON_AVAILABLE_IN_1_0
0514 guint json_array_get_length (JsonArray *array);
0515 JSON_AVAILABLE_IN_1_0
0516 void json_array_foreach_element (JsonArray *array,
0517 JsonArrayForeach func,
0518 gpointer data);
0519 JSON_AVAILABLE_IN_1_2
0520 void json_array_seal (JsonArray *array);
0521 JSON_AVAILABLE_IN_1_2
0522 gboolean json_array_is_immutable (JsonArray *array);
0523
0524 JSON_AVAILABLE_IN_1_2
0525 guint json_array_hash (gconstpointer key);
0526 JSON_AVAILABLE_IN_1_2
0527 gboolean json_array_equal (gconstpointer a,
0528 gconstpointer b);
0529
0530 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
0531 G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonArray, json_array_unref)
0532 G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonObject, json_object_unref)
0533 G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonNode, json_node_unref)
0534 #endif
0535
0536 G_END_DECLS