GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-36359e2344
|
#include "parson.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <errno.h>
Go to the source code of this file.
Macros | |
#define | PARSON_IMPL_VERSION_MAJOR 1 |
#define | PARSON_IMPL_VERSION_MINOR 5 |
#define | PARSON_IMPL_VERSION_PATCH 3 |
#define | strcpy USE_MEMCPY_INSTEAD_OF_STRCPY |
#define | STARTING_CAPACITY 16 |
#define | MAX_NESTING 2048 |
#define | PARSON_DEFAULT_FLOAT_FORMAT "%1.17g" /* do not increase precision without incresing NUM_BUF_SIZE */ |
#define | PARSON_NUM_BUF_SIZE |
#define | PARSON_INDENT_STR " " |
#define | SIZEOF_TOKEN(a) (sizeof(a) - 1) |
#define | SKIP_CHAR(str) ((*str)++) |
#define | SKIP_WHITESPACES(str) |
#define | MAX(a, b) ((a) > (b) ? (a) : (b)) |
#define | IS_NUMBER_INVALID(x) (((x) * 0.0) != 0.0) |
#define | OBJECT_INVALID_IX ((size_t) - 1) |
#define | IS_CONT(b) (((unsigned char)(b) & 0xC0) == 0x80) /* is utf-8 continuation byte */ |
#define | PARSON_TRUE 1 |
#define | PARSON_FALSE 0 |
#define | APPEND_STRING(str) |
#define | APPEND_INDENT(level) |
Typedefs | |
typedef int | parson_bool_t |
typedef struct json_string | JSON_String |
typedef union json_value_value | JSON_Value_Value |
#define APPEND_INDENT | ( | level | ) |
#define APPEND_STRING | ( | str | ) |
#define PARSON_DEFAULT_FLOAT_FORMAT "%1.17g" /* do not increase precision without incresing NUM_BUF_SIZE */ |
#define PARSON_NUM_BUF_SIZE |
#define SKIP_WHITESPACES | ( | str | ) |
typedef struct json_string JSON_String |
typedef union json_value_value JSON_Value_Value |
typedef int parson_bool_t |
JSON_Array* json_array | ( | const JSON_Value * | value | ) |
Definition at line 2800 of file parson.c.
References json_value_get_array().
JSON_Status json_array_append_boolean | ( | JSON_Array * | array, |
int | boolean | ||
) |
Definition at line 2374 of file parson.c.
References json_array_append_value(), json_value_free(), json_value_init_boolean(), JSONFailure, JSONSuccess, and NULL.
JSON_Status json_array_append_null | ( | JSON_Array * | array | ) |
Definition at line 2387 of file parson.c.
References json_array_append_value(), json_value_free(), json_value_init_null(), JSONFailure, JSONSuccess, and NULL.
JSON_Status json_array_append_number | ( | JSON_Array * | array, |
double | number | ||
) |
Definition at line 2361 of file parson.c.
References json_array_append_value(), json_value_free(), json_value_init_number(), JSONFailure, JSONSuccess, and NULL.
JSON_Status json_array_append_string | ( | JSON_Array * | array, |
const char * | string | ||
) |
Definition at line 2334 of file parson.c.
References json_array_append_value(), json_value_free(), json_value_init_string(), JSONFailure, JSONSuccess, and NULL.
JSON_Status json_array_append_string_with_len | ( | JSON_Array * | array, |
const char * | string, | ||
size_t | len | ||
) |
Definition at line 2347 of file parson.c.
References json_array_append_value(), json_value_free(), json_value_init_string_with_len(), JSONFailure, JSONSuccess, and NULL.
JSON_Status json_array_append_value | ( | JSON_Array * | array, |
JSON_Value * | value | ||
) |
Definition at line 2326 of file parson.c.
References JSONFailure, and NULL.
Referenced by json_array_append_boolean(), json_array_append_null(), json_array_append_number(), json_array_append_string(), and json_array_append_string_with_len().
JSON_Status json_array_clear | ( | JSON_Array * | array | ) |
Definition at line 2313 of file parson.c.
References json_array_get_count(), json_array_get_value(), json_value_free(), JSONFailure, JSONSuccess, and NULL.
JSON_Array* json_array_get_array | ( | const JSON_Array * | array, |
size_t | index | ||
) |
Definition at line 1789 of file parson.c.
References json_array_get_value(), and json_value_get_array().
int json_array_get_boolean | ( | const JSON_Array * | array, |
size_t | index | ||
) |
Definition at line 1794 of file parson.c.
References json_array_get_value(), and json_value_get_boolean().
size_t json_array_get_count | ( | const JSON_Array * | array | ) |
Definition at line 1799 of file parson.c.
Referenced by json_array_clear(), json_array_get_value(), json_array_remove(), json_array_replace_value(), and json_value_deep_copy().
double json_array_get_number | ( | const JSON_Array * | array, |
size_t | index | ||
) |
Definition at line 1779 of file parson.c.
References json_array_get_value(), and json_value_get_number().
JSON_Object* json_array_get_object | ( | const JSON_Array * | array, |
size_t | index | ||
) |
Definition at line 1784 of file parson.c.
References json_array_get_value(), and json_value_get_object().
const char* json_array_get_string | ( | const JSON_Array * | array, |
size_t | index | ||
) |
Definition at line 1769 of file parson.c.
References json_array_get_value(), and json_value_get_string().
size_t json_array_get_string_len | ( | const JSON_Array * | array, |
size_t | index | ||
) |
Definition at line 1774 of file parson.c.
References json_array_get_value(), and json_value_get_string_len().
JSON_Value* json_array_get_value | ( | const JSON_Array * | array, |
size_t | index | ||
) |
Definition at line 1761 of file parson.c.
References json_array_get_count(), and NULL.
Referenced by json_array_clear(), json_array_get_array(), json_array_get_boolean(), json_array_get_number(), json_array_get_object(), json_array_get_string(), json_array_get_string_len(), json_array_remove(), json_array_replace_value(), and json_value_deep_copy().
JSON_Value* json_array_get_wrapping_value | ( | const JSON_Array * | array | ) |
Definition at line 1804 of file parson.c.
References NULL.
Referenced by json_array_replace_value().
JSON_Status json_array_remove | ( | JSON_Array * | array, |
size_t | ix | ||
) |
Definition at line 2218 of file parson.c.
References json_array_get_count(), json_array_get_value(), json_value_free(), JSONFailure, JSONSuccess, and NULL.
JSON_Status json_array_replace_boolean | ( | JSON_Array * | array, |
size_t | i, | ||
int | boolean | ||
) |
Definition at line 2287 of file parson.c.
References json_array_replace_value(), json_value_free(), json_value_init_boolean(), JSONFailure, JSONSuccess, and NULL.
JSON_Status json_array_replace_null | ( | JSON_Array * | array, |
size_t | i | ||
) |
Definition at line 2300 of file parson.c.
References json_array_replace_value(), json_value_free(), json_value_init_null(), JSONFailure, JSONSuccess, and NULL.
JSON_Status json_array_replace_number | ( | JSON_Array * | array, |
size_t | i, | ||
double | number | ||
) |
Definition at line 2273 of file parson.c.
References json_array_replace_value(), json_value_free(), json_value_init_number(), JSONFailure, JSONSuccess, and NULL.
JSON_Status json_array_replace_string | ( | JSON_Array * | array, |
size_t | i, | ||
const char * | string | ||
) |
Definition at line 2245 of file parson.c.
References json_array_replace_value(), json_value_free(), json_value_init_string(), JSONFailure, JSONSuccess, and NULL.
JSON_Status json_array_replace_string_with_len | ( | JSON_Array * | array, |
size_t | i, | ||
const char * | string, | ||
size_t | len | ||
) |
Definition at line 2259 of file parson.c.
References json_array_replace_value(), json_value_free(), json_value_init_string_with_len(), JSONFailure, JSONSuccess, and NULL.
JSON_Status json_array_replace_value | ( | JSON_Array * | array, |
size_t | ix, | ||
JSON_Value * | value | ||
) |
Definition at line 2232 of file parson.c.
References json_array_get_count(), json_array_get_value(), json_array_get_wrapping_value(), json_value_free(), JSONFailure, JSONSuccess, and NULL.
Referenced by json_array_replace_boolean(), json_array_replace_null(), json_array_replace_number(), json_array_replace_string(), and json_array_replace_string_with_len().
int json_boolean | ( | const JSON_Value * | value | ) |
Definition at line 2820 of file parson.c.
References json_value_get_boolean().
double json_number | ( | const JSON_Value * | value | ) |
Definition at line 2815 of file parson.c.
References json_value_get_number().
JSON_Object* json_object | ( | const JSON_Value * | value | ) |
Definition at line 2795 of file parson.c.
References json_value_get_object().
JSON_Status json_object_clear | ( | JSON_Object * | object | ) |
Definition at line 2635 of file parson.c.
References json_object_get_count(), JSONFailure, and NULL.
JSON_Array* json_object_dotget_array | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1696 of file parson.c.
References json_object_dotget_value(), json_value_get_array(), and name.
int json_object_dotget_boolean | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1702 of file parson.c.
References json_object_dotget_value(), json_value_get_boolean(), and name.
double json_object_dotget_number | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1685 of file parson.c.
References json_object_dotget_value(), json_value_get_number(), and name.
JSON_Object* json_object_dotget_object | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1690 of file parson.c.
References json_object_dotget_value(), json_value_get_object(), and name.
const char* json_object_dotget_string | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1673 of file parson.c.
References json_object_dotget_value(), json_value_get_string(), and name.
size_t json_object_dotget_string_len | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1679 of file parson.c.
References json_object_dotget_value(), json_value_get_string_len(), and name.
JSON_Value* json_object_dotget_value | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1661 of file parson.c.
References json_object_get_value(), json_value_get_object(), and name.
Referenced by json_object_dotget_array(), json_object_dotget_boolean(), json_object_dotget_number(), json_object_dotget_object(), json_object_dotget_string(), json_object_dotget_string_len(), and json_object_dothas_value().
int json_object_dothas_value | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1748 of file parson.c.
References json_object_dotget_value(), name, and NULL.
int json_object_dothas_value_of_type | ( | const JSON_Object * | object, |
const char * | name, | ||
JSON_Value_Type | type | ||
) |
JSON_Status json_object_dotremove | ( | JSON_Object * | object, |
const char * | name | ||
) |
JSON_Status json_object_dotset_boolean | ( | JSON_Object * | object, |
const char * | name, | ||
int | boolean | ||
) |
Definition at line 2598 of file parson.c.
References json_object_dotset_value(), json_value_free(), json_value_init_boolean(), JSONFailure, JSONSuccess, name, and NULL.
JSON_Status json_object_dotset_null | ( | JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 2612 of file parson.c.
References json_object_dotset_value(), json_value_free(), json_value_init_null(), JSONFailure, JSONSuccess, name, and NULL.
JSON_Status json_object_dotset_number | ( | JSON_Object * | object, |
const char * | name, | ||
double | number | ||
) |
Definition at line 2584 of file parson.c.
References json_object_dotset_value(), json_value_free(), json_value_init_number(), JSONFailure, JSONSuccess, name, and NULL.
JSON_Status json_object_dotset_string | ( | JSON_Object * | object, |
const char * | name, | ||
const char * | string | ||
) |
Definition at line 2555 of file parson.c.
References json_object_dotset_value(), json_value_free(), json_value_init_string(), JSONFailure, JSONSuccess, name, and NULL.
JSON_Status json_object_dotset_string_with_len | ( | JSON_Object * | object, |
const char * | name, | ||
const char * | string, | ||
size_t | len | ||
) |
Definition at line 2569 of file parson.c.
References json_object_dotset_value(), json_value_free(), json_value_init_string_with_len(), JSONFailure, JSONSuccess, name, and NULL.
JSON_Status json_object_dotset_value | ( | JSON_Object * | object, |
const char * | name, | ||
JSON_Value * | value | ||
) |
Definition at line 2501 of file parson.c.
References json_object_set_value(), JSONFailure, name, and NULL.
Referenced by json_object_dotset_boolean(), json_object_dotset_null(), json_object_dotset_number(), json_object_dotset_string(), and json_object_dotset_string_with_len().
JSON_Array* json_object_get_array | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1651 of file parson.c.
References json_object_get_value(), json_value_get_array(), and name.
int json_object_get_boolean | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1656 of file parson.c.
References json_object_get_value(), json_value_get_boolean(), and name.
size_t json_object_get_count | ( | const JSON_Object * | object | ) |
Definition at line 1707 of file parson.c.
Referenced by json_object_clear(), json_object_get_name(), and json_object_get_value_at().
const char* json_object_get_name | ( | const JSON_Object * | object, |
size_t | index | ||
) |
Definition at line 1712 of file parson.c.
References json_object_get_count(), and NULL.
double json_object_get_number | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1641 of file parson.c.
References json_object_get_value(), json_value_get_number(), and name.
JSON_Object* json_object_get_object | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1646 of file parson.c.
References json_object_get_value(), json_value_get_object(), and name.
const char* json_object_get_string | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1631 of file parson.c.
References json_object_get_value(), json_value_get_string(), and name.
size_t json_object_get_string_len | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1636 of file parson.c.
References json_object_get_value(), json_value_get_string_len(), and name.
JSON_Value* json_object_get_value | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1623 of file parson.c.
Referenced by json_object_dotget_value(), json_object_get_array(), json_object_get_boolean(), json_object_get_number(), json_object_get_object(), json_object_get_string(), json_object_get_string_len(), and json_object_has_value().
JSON_Value* json_object_get_value_at | ( | const JSON_Object * | object, |
size_t | index | ||
) |
Definition at line 1720 of file parson.c.
References json_object_get_count(), and NULL.
JSON_Value* json_object_get_wrapping_value | ( | const JSON_Object * | object | ) |
int json_object_has_value | ( | const JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 1736 of file parson.c.
References json_object_get_value(), name, and NULL.
int json_object_has_value_of_type | ( | const JSON_Object * | object, |
const char * | name, | ||
JSON_Value_Type | type | ||
) |
JSON_Status json_object_remove | ( | JSON_Object * | object, |
const char * | name | ||
) |
JSON_Status json_object_set_boolean | ( | JSON_Object * | object, |
const char * | name, | ||
int | boolean | ||
) |
Definition at line 2480 of file parson.c.
References json_object_set_value(), json_value_free(), json_value_init_boolean(), JSONSuccess, and name.
JSON_Status json_object_set_null | ( | JSON_Object * | object, |
const char * | name | ||
) |
Definition at line 2491 of file parson.c.
References json_object_set_value(), json_value_free(), json_value_init_null(), JSONSuccess, and name.
JSON_Status json_object_set_number | ( | JSON_Object * | object, |
const char * | name, | ||
double | number | ||
) |
Definition at line 2469 of file parson.c.
References json_object_set_value(), json_value_free(), json_value_init_number(), JSONSuccess, and name.
JSON_Status json_object_set_string | ( | JSON_Object * | object, |
const char * | name, | ||
const char * | string | ||
) |
Definition at line 2446 of file parson.c.
References json_object_set_value(), json_value_free(), json_value_init_string(), JSONSuccess, and name.
JSON_Status json_object_set_string_with_len | ( | JSON_Object * | object, |
const char * | name, | ||
const char * | string, | ||
size_t | len | ||
) |
Definition at line 2457 of file parson.c.
References json_object_set_value(), json_value_free(), json_value_init_string_with_len(), JSONSuccess, and name.
JSON_Status json_object_set_value | ( | JSON_Object * | object, |
const char * | name, | ||
JSON_Value * | value | ||
) |
Definition at line 2400 of file parson.c.
References JSONFailure, name, NULL, and PARSON_FALSE.
Referenced by json_object_dotset_value(), json_object_set_boolean(), json_object_set_null(), json_object_set_number(), json_object_set_string(), and json_object_set_string_with_len().
JSON_Value* json_parse_file | ( | const char * | filename | ) |
JSON_Value* json_parse_file_with_comments | ( | const char * | filename | ) |
JSON_Value* json_parse_string | ( | const char * | string | ) |
JSON_Value* json_parse_string_with_comments | ( | const char * | string | ) |
size_t json_serialization_size | ( | const JSON_Value * | value | ) |
Definition at line 2076 of file parson.c.
References PARSON_NUM_BUF_SIZE.
Referenced by json_serialize_to_buffer(), and json_serialize_to_string().
size_t json_serialization_size_pretty | ( | const JSON_Value * | value | ) |
Definition at line 2144 of file parson.c.
References PARSON_NUM_BUF_SIZE.
Referenced by json_serialize_to_buffer_pretty(), and json_serialize_to_string_pretty().
JSON_Status json_serialize_to_buffer | ( | const JSON_Value * | value, |
char * | buf, | ||
size_t | buf_size_in_bytes | ||
) |
Definition at line 2085 of file parson.c.
References json_serialization_size(), and JSONFailure.
JSON_Status json_serialize_to_buffer_pretty | ( | const JSON_Value * | value, |
char * | buf, | ||
size_t | buf_size_in_bytes | ||
) |
Definition at line 2153 of file parson.c.
References json_serialization_size_pretty(), and JSONFailure.
JSON_Status json_serialize_to_file | ( | const JSON_Value * | value, |
const char * | filename | ||
) |
JSON_Status json_serialize_to_file_pretty | ( | const JSON_Value * | value, |
const char * | filename | ||
) |
char* json_serialize_to_string | ( | const JSON_Value * | value | ) |
Definition at line 2124 of file parson.c.
References json_serialization_size(), JSONFailure, and NULL.
char* json_serialize_to_string_pretty | ( | const JSON_Value * | value | ) |
Definition at line 2192 of file parson.c.
References json_serialization_size_pretty(), JSONFailure, and NULL.
void json_set_allocation_functions | ( | JSON_Malloc_Function | malloc_fun, |
JSON_Free_Function | free_fun | ||
) |
void json_set_float_serialization_format | ( | const char * | format | ) |
void json_set_number_serialization_function | ( | JSON_Number_Serialization_Function | func | ) |
const char* json_string | ( | const JSON_Value * | value | ) |
Definition at line 2805 of file parson.c.
References json_value_get_string().
size_t json_string_len | ( | const JSON_Value * | value | ) |
Definition at line 2810 of file parson.c.
References json_value_get_string_len().
JSON_Value_Type json_type | ( | const JSON_Value * | value | ) |
Definition at line 2790 of file parson.c.
References json_value_get_type().
JSON_Status json_validate | ( | const JSON_Value * | schema, |
const JSON_Value * | value | ||
) |
JSON_Value* json_value_deep_copy | ( | const JSON_Value * | value | ) |
Definition at line 1981 of file parson.c.
References json_array_get_count(), json_array_get_value(), json_value_free(), json_value_get_array(), json_value_get_type(), json_value_init_array(), JSONArray, JSONFailure, and NULL.
int json_value_equals | ( | const JSON_Value * | a, |
const JSON_Value * | b | ||
) |
void json_value_free | ( | JSON_Value * | value | ) |
Definition at line 1863 of file parson.c.
References json_value_get_type(), and JSONObject.
Referenced by json_array_append_boolean(), json_array_append_null(), json_array_append_number(), json_array_append_string(), json_array_append_string_with_len(), json_array_clear(), json_array_remove(), json_array_replace_boolean(), json_array_replace_null(), json_array_replace_number(), json_array_replace_string(), json_array_replace_string_with_len(), json_array_replace_value(), json_object_dotset_boolean(), json_object_dotset_null(), json_object_dotset_number(), json_object_dotset_string(), json_object_dotset_string_with_len(), json_object_set_boolean(), json_object_set_null(), json_object_set_number(), json_object_set_string(), json_object_set_string_with_len(), and json_value_deep_copy().
JSON_Array* json_value_get_array | ( | const JSON_Value * | value | ) |
Definition at line 1824 of file parson.c.
References json_value_get_type(), JSONArray, and NULL.
Referenced by json_array(), json_array_get_array(), json_object_dotget_array(), json_object_get_array(), and json_value_deep_copy().
int json_value_get_boolean | ( | const JSON_Value * | value | ) |
Definition at line 1852 of file parson.c.
References json_value_get_type(), and JSONBoolean.
Referenced by json_array_get_boolean(), json_boolean(), json_object_dotget_boolean(), and json_object_get_boolean().
double json_value_get_number | ( | const JSON_Value * | value | ) |
Definition at line 1847 of file parson.c.
References json_value_get_type(), and JSONNumber.
Referenced by json_array_get_number(), json_number(), json_object_dotget_number(), and json_object_get_number().
JSON_Object* json_value_get_object | ( | const JSON_Value * | value | ) |
Definition at line 1818 of file parson.c.
References json_value_get_type(), JSONObject, and NULL.
Referenced by json_array_get_object(), json_object(), json_object_dotget_object(), json_object_dotget_value(), and json_object_get_object().
JSON_Value* json_value_get_parent | ( | const JSON_Value * | value | ) |
const char* json_value_get_string | ( | const JSON_Value * | value | ) |
Definition at line 1835 of file parson.c.
Referenced by json_array_get_string(), json_object_dotget_string(), json_object_get_string(), and json_string().
size_t json_value_get_string_len | ( | const JSON_Value * | value | ) |
Definition at line 1841 of file parson.c.
Referenced by json_array_get_string_len(), json_object_dotget_string_len(), json_object_get_string_len(), and json_string_len().
JSON_Value_Type json_value_get_type | ( | const JSON_Value * | value | ) |
Definition at line 1813 of file parson.c.
References JSONError.
Referenced by json_type(), json_value_deep_copy(), json_value_free(), json_value_get_array(), json_value_get_boolean(), json_value_get_number(), and json_value_get_object().
JSON_Value* json_value_init_array | ( | void | ) |
Definition at line 1897 of file parson.c.
Referenced by json_value_deep_copy().
JSON_Value* json_value_init_boolean | ( | int | boolean | ) |
Definition at line 1958 of file parson.c.
Referenced by json_array_append_boolean(), json_array_replace_boolean(), json_object_dotset_boolean(), and json_object_set_boolean().
JSON_Value* json_value_init_null | ( | void | ) |
Definition at line 1970 of file parson.c.
Referenced by json_array_append_null(), json_array_replace_null(), json_object_dotset_null(), and json_object_set_null().
JSON_Value* json_value_init_number | ( | double | number | ) |
Definition at line 1942 of file parson.c.
References IS_NUMBER_INVALID, and NULL.
Referenced by json_array_append_number(), json_array_replace_number(), json_object_dotset_number(), and json_object_set_number().
JSON_Value* json_value_init_object | ( | void | ) |
JSON_Value* json_value_init_string | ( | const char * | string | ) |
Definition at line 1913 of file parson.c.
References json_value_init_string_with_len(), and NULL.
Referenced by json_array_append_string(), json_array_replace_string(), json_object_dotset_string(), and json_object_set_string().
JSON_Value* json_value_init_string_with_len | ( | const char * | string, |
size_t | length | ||
) |
Definition at line 1921 of file parson.c.
References NULL.
Referenced by json_array_append_string_with_len(), json_array_replace_string_with_len(), json_object_dotset_string_with_len(), json_object_set_string_with_len(), and json_value_init_string().