lib/yyjson-0.12.0/doc/doxygen/html/yyjson_8h.html
| yyjson 0.12.0
A high performance C JSON library. |
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
yyjson.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <limits.h>
#include <string.h>
#include <float.h>
|
| | struct | yyjson_alc | | | | struct | [yyjson_read_err](#structyyjson read err) | | | | struct | [yyjson_write_err](#structyyjson write err) | | | | struct | [yyjson_arr_iter](#structyyjson arr iter) | | | | struct | [yyjson_obj_iter](#structyyjson obj iter) | | | | struct | [yyjson_mut_arr_iter](#structyyjson mut arr__iter) | | | | struct | [yyjson_mut_obj_iter](#structyyjson mut obj__iter) | | | | struct | [yyjson_ptr_err](#structyyjson ptr err) | | | | struct | [yyjson_ptr_ctx](#structyyjson ptr ctx) | | | | struct | [yyjson_patch_err](#structyyjson patch err) | | | | union | [yyjson_val_uni](#unionyyjson val uni) | | | | struct | yyjson_val | | | | struct | yyjson_doc | | | | struct | [yyjson_mut_val](#structyyjson mut val) | | | | struct | [yyjson_str_chunk](#structyyjson str chunk) | | | | struct | [yyjson_str_pool](#structyyjson str pool) | | | | struct | [yyjson_val_chunk](#structyyjson val chunk) | | | | struct | [yyjson_val_pool](#structyyjson val pool) | | | | struct | [yyjson_mut_doc](#structyyjson mut doc) | | |
|
| | #define | YYJSON_MSC_VER 0 | | | | #define | YYJSON_GCC_VER 0 | | | | #define | YYJSON_IS_REAL_GCC 0 | | | | #define | YYJSON_STDC_VER 0 | | | | #define | YYJSON_CPP_VER 0 | | | | #define | yyjson_has_builtin(x) | | | | #define | yyjson_has_attribute(x) | | | | #define | yyjson_has_feature(x) | | | | #define | yyjson_has_include(x) | | | | #define | yyjson_inline | | | | #define | yyjson_noinline | | | | #define | yyjson_align(x) | | | | #define | yyjson_likely(expr) | | | | #define | yyjson_unlikely(expr) | | | | #define | YYJSON_HAS_CONSTANT_P 0 | | | | #define | yyjson_deprecated(msg) | | | | #define | yyjson_api | | | | #define | yyjson_api_inline static yyjson_inline | | | | #define | __bool_true_false_are_defined 1 | | | | #define | YYJSON_U64_TO_F64_NO_IMPL 0 | | | | #define | YYJSON_VERSION_MAJOR 0 | | | | #define | YYJSON_VERSION_MINOR 12 | | | | #define | YYJSON_VERSION_PATCH 0 | | | | #define | YYJSON_VERSION_HEX 0x000C00 | | | | #define | YYJSON_VERSION_STRING "0.12.0" | | | | #define | YYJSON_TYPE_NONE ((uint8_t)0) /* _____000 */ | | | | #define | YYJSON_TYPE_RAW ((uint8_t)1) /* _____001 */ | | | | #define | YYJSON_TYPE_NULL ((uint8_t)2) /* _____010 */ | | | | #define | YYJSON_TYPE_BOOL ((uint8_t)3) /* _____011 */ | | | | #define | YYJSON_TYPE_NUM ((uint8_t)4) /* _____100 */ | | | | #define | YYJSON_TYPE_STR ((uint8_t)5) /* _____101 */ | | | | #define | YYJSON_TYPE_ARR ((uint8_t)6) /* _____110 */ | | | | #define | YYJSON_TYPE_OBJ ((uint8_t)7) /* _____111 */ | | | | #define | YYJSON_SUBTYPE_NONE ((uint8_t)(0 << 3)) /* ___00___ */ | | | | #define | YYJSON_SUBTYPE_FALSE ((uint8_t)(0 << 3)) /* ___00___ */ | | | | #define | YYJSON_SUBTYPE_TRUE ((uint8_t)(1 << 3)) /* ___01___ */ | | | | #define | YYJSON_SUBTYPE_UINT ((uint8_t)(0 << 3)) /* ___00___ */ | | | | #define | YYJSON_SUBTYPE_SINT ((uint8_t)(1 << 3)) /* ___01___ */ | | | | #define | YYJSON_SUBTYPE_REAL ((uint8_t)(2 << 3)) /* ___10___ */ | | | | #define | YYJSON_SUBTYPE_NOESC ((uint8_t)(1 << 3)) /* ___01___ */ | | | | #define | YYJSON_TYPE_MASK ((uint8_t)0x07) /* _____111 */ | | | | #define | YYJSON_TYPE_BIT ((uint8_t)3) | | | | #define | YYJSON_SUBTYPE_MASK ((uint8_t)0x18) /* ___11___ */ | | | | #define | YYJSON_SUBTYPE_BIT ((uint8_t)2) | | | | #define | YYJSON_RESERVED_MASK ((uint8_t)0xE0) /* 111_____ */ | | | | #define | YYJSON_RESERVED_BIT ((uint8_t)3) | | | | #define | YYJSON_TAG_MASK ((uint8_t)0xFF) /* 11111111 */ | | | | #define | YYJSON_TAG_BIT ((uint8_t)8) | | | | #define | YYJSON_PADDING_SIZE 4 | | | | #define | YYJSON_WRITE_FP_FLAG_BITS 8 | | | | #define | YYJSON_WRITE_FP_PREC_BITS 4 | | | | #define | YYJSON_WRITE_FP_TO_FIXED(prec) | | | | #define | YYJSON_WRITE_FP_TO_FLOAT ((yyjson_write_flag)(1 << (32 - 5))) | | | | #define | yyjson_arr_foreach(arr, idx, max, val) | | | | #define | yyjson_obj_foreach(obj, idx, max, key, val) | | | | #define | yyjson_mut_arr_foreach(arr, idx, max, val) | | | | #define | yyjson_mut_obj_foreach(obj, idx, max, key, val) | | |
|
| | typedef uint8_t | yyjson_type | | | | typedef uint8_t | yyjson_subtype | | | | typedef uint32_t | yyjson_read_flag | | | | typedef uint32_t | yyjson_read_code | | | | typedef struct yyjson_incr_state | yyjson_incr_state | | | | typedef uint32_t | yyjson_write_flag | | | | typedef uint32_t | yyjson_write_code | | | | typedef uint32_t | yyjson_ptr_code | | | | typedef uint32_t | yyjson_patch_code | | |
|
| | yyjson_api uint32_t | yyjson_version (void) | | | | yyjson_api bool | yyjson_alc_pool_init (yyjson_alc *alc, void *buf, size_t size) | | | | yyjson_api yyjson_alc * | yyjson_alc_dyn_new (void) | | | | yyjson_api void | yyjson_alc_dyn_free (yyjson_alc *alc) | | | | yyjson_api bool | yyjson_locate_pos (const char *str, size_t len, size_t pos, size_t *line, size_t *col, size_t *chr) | | | | yyjson_api yyjson_doc * | yyjson_read_opts (char *dat, size_t len, yyjson_read_flag flg, const yyjson_alc *alc, [yyjson_read_err](#structyyjson read err) *err) | | | | yyjson_api yyjson_doc * | yyjson_read_file (const char *path, yyjson_read_flag flg, const yyjson_alc *alc, [yyjson_read_err](#structyyjson read err) *err) | | | | yyjson_api yyjson_doc * | yyjson_read_fp (FILE *fp, yyjson_read_flag flg, const yyjson_alc *alc, [yyjson_read_err](#structyyjson read err) *err) | | | | yyjson_api_inline yyjson_doc * | yyjson_read (const char *dat, size_t len, yyjson_read_flag flg) | | | | yyjson_api yyjson_incr_state * | yyjson_incr_new (char *buf, size_t buf_len, yyjson_read_flag flg, const yyjson_alc *alc) | | | | yyjson_api yyjson_doc * | yyjson_incr_read (yyjson_incr_state *state, size_t len, yyjson_read_err *err) | | | | yyjson_api void | yyjson_incr_free (yyjson_incr_state *state) | | | | yyjson_api_inline size_t | yyjson_read_max_memory_usage (size_t len, yyjson_read_flag flg) | | | | yyjson_api const char * | yyjson_read_number (const char *dat, yyjson_val *val, yyjson_read_flag flg, const yyjson_alc *alc, [yyjson_read_err](#structyyjson read err) *err) | | | | yyjson_api_inline const char * | yyjson_mut_read_number (const char *dat, [yyjson_mut_val](#structyyjson mut val) *val, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err) | | | | yyjson_api char * | yyjson_write_opts (const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, [yyjson_write_err](#structyyjson write err) *err) | | | | yyjson_api bool | yyjson_write_file (const char *path, const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, [yyjson_write_err](#structyyjson write err) *err) | | | | yyjson_api bool | yyjson_write_fp (FILE *fp, const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, [yyjson_write_err](#structyyjson write err) *err) | | | | yyjson_api_inline char * | yyjson_write (const yyjson_doc *doc, yyjson_write_flag flg, size_t *len) | | | | yyjson_api char * | yyjson_mut_write_opts (const [yyjson_mut_doc](#structyyjson mut doc) *doc, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, yyjson_write_err *err) | | | | yyjson_api bool | yyjson_mut_write_file (const char *path, const [yyjson_mut_doc](#structyyjson mut doc) *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err) | | | | yyjson_api bool | yyjson_mut_write_fp (FILE *fp, const [yyjson_mut_doc](#structyyjson mut doc) *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err) | | | | yyjson_api_inline char * | yyjson_mut_write (const [yyjson_mut_doc](#structyyjson mut doc) *doc, yyjson_write_flag flg, size_t *len) | | | | yyjson_api char * | yyjson_val_write_opts (const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, [yyjson_write_err](#structyyjson write err) *err) | | | | yyjson_api bool | yyjson_val_write_file (const char *path, const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc, [yyjson_write_err](#structyyjson write err) *err) | | | | yyjson_api bool | yyjson_val_write_fp (FILE *fp, const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc, [yyjson_write_err](#structyyjson write err) *err) | | | | yyjson_api_inline char * | yyjson_val_write (const yyjson_val *val, yyjson_write_flag flg, size_t *len) | | | | yyjson_api char * | yyjson_mut_val_write_opts (const [yyjson_mut_val](#structyyjson mut val) *val, yyjson_write_flag flg, const yyjson_alc *alc, size_t *len, yyjson_write_err *err) | | | | yyjson_api bool | yyjson_mut_val_write_file (const char *path, const [yyjson_mut_val](#structyyjson mut val) *val, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err) | | | | yyjson_api bool | yyjson_mut_val_write_fp (FILE *fp, const [yyjson_mut_val](#structyyjson mut val) *val, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err) | | | | yyjson_api_inline char * | yyjson_mut_val_write (const [yyjson_mut_val](#structyyjson mut val) *val, yyjson_write_flag flg, size_t *len) | | | | yyjson_api char * | yyjson_write_number (const yyjson_val *val, char *buf) | | | | yyjson_api_inline char * | yyjson_mut_write_number (const [yyjson_mut_val](#structyyjson mut val) *val, char *buf) | | | | yyjson_api_inline yyjson_val * | yyjson_doc_get_root (yyjson_doc *doc) | | | | yyjson_api_inline size_t | yyjson_doc_get_read_size (yyjson_doc *doc) | | | | yyjson_api_inline size_t | yyjson_doc_get_val_count (yyjson_doc *doc) | | | | yyjson_api_inline void | yyjson_doc_free (yyjson_doc *doc) | | | | yyjson_api_inline bool | yyjson_is_raw (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_null (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_true (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_false (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_bool (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_uint (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_sint (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_int (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_real (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_num (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_str (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_arr (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_obj (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_is_ctn (yyjson_val *val) | | | | yyjson_api_inline yyjson_type | yyjson_get_type (yyjson_val *val) | | | | yyjson_api_inline yyjson_subtype | yyjson_get_subtype (yyjson_val *val) | | | | yyjson_api_inline uint8_t | yyjson_get_tag (yyjson_val *val) | | | | yyjson_api_inline const char * | yyjson_get_type_desc (yyjson_val *val) | | | | yyjson_api_inline const char * | yyjson_get_raw (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_get_bool (yyjson_val *val) | | | | yyjson_api_inline uint64_t | yyjson_get_uint (yyjson_val *val) | | | | yyjson_api_inline int64_t | yyjson_get_sint (yyjson_val *val) | | | | yyjson_api_inline int | yyjson_get_int (yyjson_val *val) | | | | yyjson_api_inline double | yyjson_get_real (yyjson_val *val) | | | | yyjson_api_inline double | yyjson_get_num (yyjson_val *val) | | | | yyjson_api_inline const char * | yyjson_get_str (yyjson_val *val) | | | | yyjson_api_inline size_t | yyjson_get_len (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_equals_str (yyjson_val *val, const char *str) | | | | yyjson_api_inline bool | yyjson_equals_strn (yyjson_val *val, const char *str, size_t len) | | | | yyjson_api_inline bool | yyjson_equals (yyjson_val *lhs, yyjson_val *rhs) | | | | yyjson_api_inline bool | yyjson_set_raw (yyjson_val *val, const char *raw, size_t len) | | | | yyjson_api_inline bool | yyjson_set_null (yyjson_val *val) | | | | yyjson_api_inline bool | yyjson_set_bool (yyjson_val *val, bool num) | | | | yyjson_api_inline bool | yyjson_set_uint (yyjson_val *val, uint64_t num) | | | | yyjson_api_inline bool | yyjson_set_sint (yyjson_val *val, int64_t num) | | | | yyjson_api_inline bool | yyjson_set_int (yyjson_val *val, int num) | | | | yyjson_api_inline bool | yyjson_set_float (yyjson_val *val, float num) | | | | yyjson_api_inline bool | yyjson_set_double (yyjson_val *val, double num) | | | | yyjson_api_inline bool | yyjson_set_real (yyjson_val *val, double num) | | | | yyjson_api_inline bool | yyjson_set_fp_to_fixed (yyjson_val *val, int prec) | | | | yyjson_api_inline bool | yyjson_set_fp_to_float (yyjson_val *val, bool flt) | | | | yyjson_api_inline bool | yyjson_set_str (yyjson_val *val, const char *str) | | | | yyjson_api_inline bool | yyjson_set_strn (yyjson_val *val, const char *str, size_t len) | | | | yyjson_api_inline bool | yyjson_set_str_noesc (yyjson_val *val, bool noesc) | | | | yyjson_api_inline size_t | yyjson_arr_size (yyjson_val *arr) | | | | yyjson_api_inline yyjson_val * | yyjson_arr_get (yyjson_val *arr, size_t idx) | | | | yyjson_api_inline yyjson_val * | yyjson_arr_get_first (yyjson_val *arr) | | | | yyjson_api_inline yyjson_val * | yyjson_arr_get_last (yyjson_val *arr) | | | | yyjson_api_inline bool | yyjson_arr_iter_init (yyjson_val *arr, yyjson_arr_iter *iter) | | | | yyjson_api_inline [yyjson_arr_iter](#structyyjson arr iter) | yyjson_arr_iter_with (yyjson_val *arr) | | | | yyjson_api_inline bool | yyjson_arr_iter_has_next ([yyjson_arr_iter](#structyyjson arr iter) *iter) | | | | yyjson_api_inline yyjson_val * | yyjson_arr_iter_next (yyjson_arr_iter *iter) | | | | yyjson_api_inline size_t | yyjson_obj_size (yyjson_val *obj) | | | | yyjson_api_inline yyjson_val * | yyjson_obj_get (yyjson_val *obj, const char *key) | | | | yyjson_api_inline yyjson_val * | yyjson_obj_getn (yyjson_val *obj, const char *key, size_t key_len) | | | | yyjson_api_inline bool | yyjson_obj_iter_init (yyjson_val *obj, yyjson_obj_iter *iter) | | | | yyjson_api_inline [yyjson_obj_iter](#structyyjson obj iter) | yyjson_obj_iter_with (yyjson_val *obj) | | | | yyjson_api_inline bool | yyjson_obj_iter_has_next ([yyjson_obj_iter](#structyyjson obj iter) *iter) | | | | yyjson_api_inline yyjson_val * | yyjson_obj_iter_next (yyjson_obj_iter *iter) | | | | yyjson_api_inline yyjson_val * | yyjson_obj_iter_get_val (yyjson_val *key) | | | | yyjson_api_inline yyjson_val * | yyjson_obj_iter_get (yyjson_obj_iter *iter, const char *key) | | | | yyjson_api_inline yyjson_val * | yyjson_obj_iter_getn (yyjson_obj_iter *iter, const char *key, size_t key_len) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_doc_get_root ([yyjson_mut_doc](#structyyjson mut doc) *doc) | | | | yyjson_api_inline void | yyjson_mut_doc_set_root ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *root) | | | | yyjson_api bool | yyjson_mut_doc_set_str_pool_size ([yyjson_mut_doc](#structyyjson mut doc) *doc, size_t len) | | | | yyjson_api bool | yyjson_mut_doc_set_val_pool_size ([yyjson_mut_doc](#structyyjson mut doc) *doc, size_t count) | | | | yyjson_api void | yyjson_mut_doc_free ([yyjson_mut_doc](#structyyjson mut doc) *doc) | | | | yyjson_api [yyjson_mut_doc](#structyyjson mut doc) * | yyjson_mut_doc_new (const yyjson_alc *alc) | | | | yyjson_api [yyjson_mut_doc](#structyyjson mut doc) * | yyjson_doc_mut_copy (yyjson_doc *doc, const yyjson_alc *alc) | | | | yyjson_api [yyjson_mut_doc](#structyyjson mut doc) * | yyjson_mut_doc_mut_copy ([yyjson_mut_doc](#structyyjson mut doc) *doc, const yyjson_alc *alc) | | | | yyjson_api [yyjson_mut_val](#structyyjson mut val) * | yyjson_val_mut_copy ([yyjson_mut_doc](#structyyjson mut doc) *doc, yyjson_val *val) | | | | yyjson_api [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_val_mut_copy ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api yyjson_doc * | yyjson_mut_doc_imut_copy (yyjson_mut_doc *doc, const yyjson_alc *alc) | | | | yyjson_api yyjson_doc * | yyjson_mut_val_imut_copy (yyjson_mut_val *val, const yyjson_alc *alc) | | | | yyjson_api_inline bool | yyjson_mut_is_raw ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_null ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_true ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_false ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_bool ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_uint ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_sint ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_int ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_real ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_num ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_str ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_arr ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_obj ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_is_ctn ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline yyjson_type | yyjson_mut_get_type ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline yyjson_subtype | yyjson_mut_get_subtype ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline uint8_t | yyjson_mut_get_tag ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline const char * | yyjson_mut_get_type_desc ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline const char * | yyjson_mut_get_raw ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_get_bool ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline uint64_t | yyjson_mut_get_uint ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline int64_t | yyjson_mut_get_sint ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline int | yyjson_mut_get_int ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline double | yyjson_mut_get_real ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline double | yyjson_mut_get_num ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline const char * | yyjson_mut_get_str ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline size_t | yyjson_mut_get_len ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_equals_str ([yyjson_mut_val](#structyyjson mut val) *val, const char *str) | | | | yyjson_api_inline bool | yyjson_mut_equals_strn ([yyjson_mut_val](#structyyjson mut val) *val, const char *str, size_t len) | | | | yyjson_api_inline bool | yyjson_mut_equals ([yyjson_mut_val](#structyyjson mut val) *lhs, [yyjson_mut_val](#structyyjson mut val) *rhs) | | | | yyjson_api_inline bool | yyjson_mut_set_raw ([yyjson_mut_val](#structyyjson mut val) *val, const char *raw, size_t len) | | | | yyjson_api_inline bool | yyjson_mut_set_null ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_set_bool ([yyjson_mut_val](#structyyjson mut val) *val, bool num) | | | | yyjson_api_inline bool | yyjson_mut_set_uint ([yyjson_mut_val](#structyyjson mut val) *val, uint64_t num) | | | | yyjson_api_inline bool | yyjson_mut_set_sint ([yyjson_mut_val](#structyyjson mut val) *val, int64_t num) | | | | yyjson_api_inline bool | yyjson_mut_set_int ([yyjson_mut_val](#structyyjson mut val) *val, int num) | | | | yyjson_api_inline bool | yyjson_mut_set_float ([yyjson_mut_val](#structyyjson mut val) *val, float num) | | | | yyjson_api_inline bool | yyjson_mut_set_double ([yyjson_mut_val](#structyyjson mut val) *val, double num) | | | | yyjson_api_inline bool | yyjson_mut_set_real ([yyjson_mut_val](#structyyjson mut val) *val, double num) | | | | yyjson_api_inline bool | yyjson_mut_set_fp_to_fixed ([yyjson_mut_val](#structyyjson mut val) *val, int prec) | | | | yyjson_api_inline bool | yyjson_mut_set_fp_to_float ([yyjson_mut_val](#structyyjson mut val) *val, bool flt) | | | | yyjson_api_inline bool | yyjson_mut_set_str ([yyjson_mut_val](#structyyjson mut val) *val, const char *str) | | | | yyjson_api_inline bool | yyjson_mut_set_strn ([yyjson_mut_val](#structyyjson mut val) *val, const char *str, size_t len) | | | | yyjson_api_inline bool | yyjson_mut_set_str_noesc ([yyjson_mut_val](#structyyjson mut val) *val, bool noesc) | | | | yyjson_api_inline bool | yyjson_mut_set_arr ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_set_obj ([yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_raw ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *str) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_rawn ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *str, size_t len) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_rawcpy ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *str) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_rawncpy ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *str, size_t len) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_null ([yyjson_mut_doc](#structyyjson mut doc) *doc) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_true ([yyjson_mut_doc](#structyyjson mut doc) *doc) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_false ([yyjson_mut_doc](#structyyjson mut doc) *doc) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_bool ([yyjson_mut_doc](#structyyjson mut doc) *doc, bool val) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_uint ([yyjson_mut_doc](#structyyjson mut doc) *doc, uint64_t num) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_sint ([yyjson_mut_doc](#structyyjson mut doc) *doc, int64_t num) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_int ([yyjson_mut_doc](#structyyjson mut doc) *doc, int64_t num) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_float ([yyjson_mut_doc](#structyyjson mut doc) *doc, float num) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_double ([yyjson_mut_doc](#structyyjson mut doc) *doc, double num) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_real ([yyjson_mut_doc](#structyyjson mut doc) *doc, double num) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_str ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *str) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_strn ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *str, size_t len) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_strcpy ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *str) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_strncpy ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *str, size_t len) | | | | yyjson_api_inline size_t | yyjson_mut_arr_size ([yyjson_mut_val](#structyyjson mut val) *arr) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_get ([yyjson_mut_val](#structyyjson mut val) *arr, size_t idx) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_get_first ([yyjson_mut_val](#structyyjson mut val) *arr) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_get_last ([yyjson_mut_val](#structyyjson mut val) *arr) | | | | yyjson_api_inline bool | yyjson_mut_arr_iter_init ([yyjson_mut_val](#structyyjson mut val) *arr, [yyjson_mut_arr_iter](#structyyjson mut arr__iter) *iter) | | | | yyjson_api_inline [yyjson_mut_arr_iter](#structyyjson mut arr__iter) | yyjson_mut_arr_iter_with (yyjson_mut_val *arr) | | | | yyjson_api_inline bool | yyjson_mut_arr_iter_has_next ([yyjson_mut_arr_iter](#structyyjson mut arr__iter) *iter) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_iter_next ([yyjson_mut_arr_iter](#structyyjson mut arr__iter) *iter) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_iter_remove ([yyjson_mut_arr_iter](#structyyjson mut arr__iter) *iter) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr ([yyjson_mut_doc](#structyyjson mut doc) *doc) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_bool ([yyjson_mut_doc](#structyyjson mut doc) *doc, const bool *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_sint ([yyjson_mut_doc](#structyyjson mut doc) *doc, const int64_t *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_uint ([yyjson_mut_doc](#structyyjson mut doc) *doc, const uint64_t *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_real ([yyjson_mut_doc](#structyyjson mut doc) *doc, const double *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_sint8 ([yyjson_mut_doc](#structyyjson mut doc) *doc, const int8_t *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_sint16 ([yyjson_mut_doc](#structyyjson mut doc) *doc, const int16_t *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_sint32 ([yyjson_mut_doc](#structyyjson mut doc) *doc, const int32_t *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_sint64 ([yyjson_mut_doc](#structyyjson mut doc) *doc, const int64_t *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_uint8 ([yyjson_mut_doc](#structyyjson mut doc) *doc, const uint8_t *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_uint16 ([yyjson_mut_doc](#structyyjson mut doc) *doc, const uint16_t *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_uint32 ([yyjson_mut_doc](#structyyjson mut doc) *doc, const uint32_t *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_uint64 ([yyjson_mut_doc](#structyyjson mut doc) *doc, const uint64_t *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_float ([yyjson_mut_doc](#structyyjson mut doc) *doc, const float *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_double ([yyjson_mut_doc](#structyyjson mut doc) *doc, const double *vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_str ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char **vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_strn ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char **vals, const size_t *lens, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_strcpy ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char **vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_with_strncpy ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char **vals, const size_t *lens, size_t count) | | | | yyjson_api_inline bool | yyjson_mut_arr_insert ([yyjson_mut_val](#structyyjson mut val) *arr, [yyjson_mut_val](#structyyjson mut val) *val, size_t idx) | | | | yyjson_api_inline bool | yyjson_mut_arr_append ([yyjson_mut_val](#structyyjson mut val) *arr, [yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_arr_prepend ([yyjson_mut_val](#structyyjson mut val) *arr, [yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_replace ([yyjson_mut_val](#structyyjson mut val) *arr, size_t idx, [yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_remove ([yyjson_mut_val](#structyyjson mut val) *arr, size_t idx) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_remove_first ([yyjson_mut_val](#structyyjson mut val) *arr) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_remove_last ([yyjson_mut_val](#structyyjson mut val) *arr) | | | | yyjson_api_inline bool | yyjson_mut_arr_remove_range ([yyjson_mut_val](#structyyjson mut val) *arr, size_t idx, size_t len) | | | | yyjson_api_inline bool | yyjson_mut_arr_clear ([yyjson_mut_val](#structyyjson mut val) *arr) | | | | yyjson_api_inline bool | yyjson_mut_arr_rotate ([yyjson_mut_val](#structyyjson mut val) *arr, size_t idx) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_val ([yyjson_mut_val](#structyyjson mut val) *arr, [yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_null ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_true ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_false ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_bool ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr, bool val) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_uint ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr, uint64_t num) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_sint ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr, int64_t num) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_int ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr, int64_t num) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_float ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr, float num) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_double ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr, double num) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_real ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr, double num) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_str ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr, const char *str) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_strn ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr, const char *str, size_t len) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_strcpy ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr, const char *str) | | | | yyjson_api_inline bool | yyjson_mut_arr_add_strncpy ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr, const char *str, size_t len) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_add_arr ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_arr_add_obj ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *arr) | | | | yyjson_api_inline size_t | yyjson_mut_obj_size ([yyjson_mut_val](#structyyjson mut val) *obj) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_get ([yyjson_mut_val](#structyyjson mut val) *obj, const char *key) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_getn ([yyjson_mut_val](#structyyjson mut val) *obj, const char *key, size_t key_len) | | | | yyjson_api_inline bool | yyjson_mut_obj_iter_init ([yyjson_mut_val](#structyyjson mut val) *obj, [yyjson_mut_obj_iter](#structyyjson mut obj__iter) *iter) | | | | yyjson_api_inline [yyjson_mut_obj_iter](#structyyjson mut obj__iter) | yyjson_mut_obj_iter_with (yyjson_mut_val *obj) | | | | yyjson_api_inline bool | yyjson_mut_obj_iter_has_next ([yyjson_mut_obj_iter](#structyyjson mut obj__iter) *iter) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_iter_next ([yyjson_mut_obj_iter](#structyyjson mut obj__iter) *iter) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_iter_get_val ([yyjson_mut_val](#structyyjson mut val) *key) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_iter_remove ([yyjson_mut_obj_iter](#structyyjson mut obj__iter) *iter) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_iter_get ([yyjson_mut_obj_iter](#structyyjson mut obj__iter) *iter, const char *key) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_iter_getn ([yyjson_mut_obj_iter](#structyyjson mut obj__iter) *iter, const char *key, size_t key_len) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj ([yyjson_mut_doc](#structyyjson mut doc) *doc) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_with_str ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char **keys, const char **vals, size_t count) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_with_kv ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char **kv_pairs, size_t pair_count) | | | | yyjson_api_inline bool | yyjson_mut_obj_add ([yyjson_mut_val](#structyyjson mut val) *obj, [yyjson_mut_val](#structyyjson mut val) *key, [yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_obj_put ([yyjson_mut_val](#structyyjson mut val) *obj, [yyjson_mut_val](#structyyjson mut val) *key, [yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_obj_insert ([yyjson_mut_val](#structyyjson mut val) *obj, [yyjson_mut_val](#structyyjson mut val) *key, [yyjson_mut_val](#structyyjson mut val) *val, size_t idx) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_remove ([yyjson_mut_val](#structyyjson mut val) *obj, [yyjson_mut_val](#structyyjson mut val) *key) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_remove_key ([yyjson_mut_val](#structyyjson mut val) *obj, const char *key) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_remove_keyn ([yyjson_mut_val](#structyyjson mut val) *obj, const char *key, size_t key_len) | | | | yyjson_api_inline bool | yyjson_mut_obj_clear ([yyjson_mut_val](#structyyjson mut val) *obj) | | | | yyjson_api_inline bool | yyjson_mut_obj_replace ([yyjson_mut_val](#structyyjson mut val) *obj, [yyjson_mut_val](#structyyjson mut val) *key, [yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_mut_obj_rotate ([yyjson_mut_val](#structyyjson mut val) *obj, size_t idx) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_null ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_true ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_false ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_bool ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, bool val) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_uint ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, uint64_t val) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_sint ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, int64_t val) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_int ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, int64_t val) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_float ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, float val) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_double ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, double val) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_real ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, double val) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_str ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, const char *val) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_strn ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, const char *val, size_t len) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_strcpy ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, const char *val) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_strncpy ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, const char *val, size_t len) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_add_arr ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_add_obj ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key) | | | | yyjson_api_inline bool | yyjson_mut_obj_add_val ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, [yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_remove_str ([yyjson_mut_val](#structyyjson mut val) *obj, const char *key) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_obj_remove_strn ([yyjson_mut_val](#structyyjson mut val) *obj, const char *key, size_t len) | | | | yyjson_api_inline bool | yyjson_mut_obj_rename_key ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, const char *new_key) | | | | yyjson_api_inline bool | yyjson_mut_obj_rename_keyn ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *obj, const char *key, size_t len, const char *new_key, size_t new_len) | | | | yyjson_api_inline yyjson_val * | yyjson_doc_ptr_get (yyjson_doc *doc, const char *ptr) | | | | yyjson_api_inline yyjson_val * | yyjson_doc_ptr_getn (yyjson_doc *doc, const char *ptr, size_t len) | | | | yyjson_api_inline yyjson_val * | yyjson_doc_ptr_getx (yyjson_doc *doc, const char *ptr, size_t len, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline yyjson_val * | yyjson_ptr_get (yyjson_val *val, const char *ptr) | | | | yyjson_api_inline yyjson_val * | yyjson_ptr_getn (yyjson_val *val, const char *ptr, size_t len) | | | | yyjson_api_inline yyjson_val * | yyjson_ptr_getx (yyjson_val *val, const char *ptr, size_t len, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_doc_ptr_get ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_doc_ptr_getn ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, size_t len) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_doc_ptr_getx ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, size_t len, [yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_ptr_get ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_ptr_getn ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, size_t len) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_ptr_getx ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, size_t len, [yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline bool | yyjson_mut_doc_ptr_add ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, [yyjson_mut_val](#structyyjson mut val) *new_val) | | | | yyjson_api_inline bool | yyjson_mut_doc_ptr_addn ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val) | | | | yyjson_api_inline bool | yyjson_mut_doc_ptr_addx ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val, bool create_parent, [yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline bool | yyjson_mut_ptr_add ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, [yyjson_mut_val](#structyyjson mut val) *new_val, [yyjson_mut_doc](#structyyjson mut doc) *doc) | | | | yyjson_api_inline bool | yyjson_mut_ptr_addn ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val, [yyjson_mut_doc](#structyyjson mut doc) *doc) | | | | yyjson_api_inline bool | yyjson_mut_ptr_addx ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val, [yyjson_mut_doc](#structyyjson mut doc) *doc, bool create_parent, [yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline bool | yyjson_mut_doc_ptr_set ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, [yyjson_mut_val](#structyyjson mut val) *new_val) | | | | yyjson_api_inline bool | yyjson_mut_doc_ptr_setn ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val) | | | | yyjson_api_inline bool | yyjson_mut_doc_ptr_setx ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val, bool create_parent, [yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline bool | yyjson_mut_ptr_set ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, [yyjson_mut_val](#structyyjson mut val) *new_val, [yyjson_mut_doc](#structyyjson mut doc) *doc) | | | | yyjson_api_inline bool | yyjson_mut_ptr_setn ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val, [yyjson_mut_doc](#structyyjson mut doc) *doc) | | | | yyjson_api_inline bool | yyjson_mut_ptr_setx ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val, [yyjson_mut_doc](#structyyjson mut doc) *doc, bool create_parent, [yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_doc_ptr_replace ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, [yyjson_mut_val](#structyyjson mut val) *new_val) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_doc_ptr_replacen ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_doc_ptr_replacex ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val, [yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_ptr_replace ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, [yyjson_mut_val](#structyyjson mut val) *new_val) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_ptr_replacen ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_ptr_replacex ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, size_t len, [yyjson_mut_val](#structyyjson mut val) *new_val, [yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_doc_ptr_remove ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_doc_ptr_removen ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, size_t len) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_doc_ptr_removex ([yyjson_mut_doc](#structyyjson mut doc) *doc, const char *ptr, size_t len, [yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_ptr_remove ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_ptr_removen ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, size_t len) | | | | yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_ptr_removex ([yyjson_mut_val](#structyyjson mut val) *val, const char *ptr, size_t len, [yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_ptr_err](#structyyjson ptr err) *err) | | | | yyjson_api_inline bool | yyjson_ptr_ctx_append ([yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_mut_val](#structyyjson mut val) *key, [yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_ptr_ctx_replace ([yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx, [yyjson_mut_val](#structyyjson mut val) *val) | | | | yyjson_api_inline bool | yyjson_ptr_ctx_remove ([yyjson_ptr_ctx](#structyyjson ptr ctx) *ctx) | | | | yyjson_api [yyjson_mut_val](#structyyjson mut val) * | yyjson_patch ([yyjson_mut_doc](#structyyjson mut doc) *doc, yyjson_val *orig, yyjson_val *patch, [yyjson_patch_err](#structyyjson patch err) *err) | | | | yyjson_api [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_patch ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *orig, [yyjson_mut_val](#structyyjson mut val) *patch, [yyjson_patch_err](#structyyjson patch err) *err) | | | | yyjson_api [yyjson_mut_val](#structyyjson mut val) * | yyjson_merge_patch ([yyjson_mut_doc](#structyyjson mut doc) *doc, yyjson_val *orig, yyjson_val *patch) | | | | yyjson_api [yyjson_mut_val](#structyyjson mut val) * | yyjson_mut_merge_patch ([yyjson_mut_doc](#structyyjson mut doc) *doc, [yyjson_mut_val](#structyyjson mut val) *orig, [yyjson_mut_val](#structyyjson mut val) *patch) | | | | yyjson_api_inline bool | yyjson_ptr_get_bool (yyjson_val *root, const char *ptr, bool *value) | | | | yyjson_api_inline bool | yyjson_ptr_get_uint (yyjson_val *root, const char *ptr, uint64_t *value) | | | | yyjson_api_inline bool | yyjson_ptr_get_sint (yyjson_val *root, const char *ptr, int64_t *value) | | | | yyjson_api_inline bool | yyjson_ptr_get_real (yyjson_val *root, const char *ptr, double *value) | | | | yyjson_api_inline bool | yyjson_ptr_get_num (yyjson_val *root, const char *ptr, double *value) | | | | yyjson_api_inline bool | yyjson_ptr_get_str (yyjson_val *root, const char *ptr, const char **value) | | | | | yyjson_deprecated ("renamed to yyjson_doc_ptr_get") yyjson_api_inline yyjson_val *yyjson_doc_get_pointer(yyjson_doc *doc | | | | | yyjson_deprecated ("renamed to yyjson_doc_ptr_getn") yyjson_api_inline yyjson_val *yyjson_doc_get_pointern(yyjson_doc *doc | | | | | yyjson_deprecated ("renamed to yyjson_mut_doc_ptr_get") yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) *yyjson_mut_doc_get_pointer([yyjson_mut_doc](#structyyjson mut doc) *doc | | | | | yyjson_deprecated ("renamed to yyjson_mut_doc_ptr_getn") yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) *yyjson_mut_doc_get_pointern([yyjson_mut_doc](#structyyjson mut doc) *doc | | | | | yyjson_deprecated ("renamed to yyjson_ptr_get") yyjson_api_inline yyjson_val *yyjson_get_pointer(yyjson_val *val | | | | | yyjson_deprecated ("renamed to yyjson_ptr_getn") yyjson_api_inline yyjson_val *yyjson_get_pointern(yyjson_val *val | | | | | yyjson_deprecated ("renamed to yyjson_mut_ptr_get") yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) *yyjson_mut_get_pointer([yyjson_mut_val](#structyyjson mut val) *val | | | | | yyjson_deprecated ("renamed to yyjson_mut_ptr_getn") yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) *yyjson_mut_get_pointern([yyjson_mut_val](#structyyjson mut val) *val | | | | | yyjson_deprecated ("renamed to unsafe_yyjson_ptr_getn") yyjson_api_inline yyjson_val *unsafe_yyjson_get_pointer(yyjson_val *val | | | | | yyjson_deprecated ("renamed to unsafe_yyjson_mut_ptr_getx") yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) *unsafe_yyjson_mut_get_pointer([yyjson_mut_val](#structyyjson mut val) *val | | |
|
| | static const yyjson_read_flag | YYJSON_READ_NOFLAG = 0 | | | | static const yyjson_read_flag | YYJSON_READ_INSITU = 1 << 0 | | | | static const yyjson_read_flag | YYJSON_READ_STOP_WHEN_DONE = 1 << 1 | | | | static const yyjson_read_flag | YYJSON_READ_ALLOW_TRAILING_COMMAS = 1 << 2 | | | | static const yyjson_read_flag | YYJSON_READ_ALLOW_COMMENTS = 1 << 3 | | | | static const yyjson_read_flag | YYJSON_READ_ALLOW_INF_AND_NAN = 1 << 4 | | | | static const yyjson_read_flag | YYJSON_READ_NUMBER_AS_RAW = 1 << 5 | | | | static const yyjson_read_flag | YYJSON_READ_ALLOW_INVALID_UNICODE = 1 << 6 | | | | static const yyjson_read_flag | YYJSON_READ_BIGNUM_AS_RAW = 1 << 7 | | | | static const yyjson_read_flag | YYJSON_READ_ALLOW_BOM = 1 << 8 | | | | static const yyjson_read_flag | YYJSON_READ_ALLOW_EXT_NUMBER = 1 << 9 | | | | static const yyjson_read_flag | YYJSON_READ_ALLOW_EXT_ESCAPE = 1 << 10 | | | | static const yyjson_read_flag | YYJSON_READ_ALLOW_EXT_WHITESPACE = 1 << 11 | | | | static const yyjson_read_flag | YYJSON_READ_ALLOW_SINGLE_QUOTED_STR = 1 << 12 | | | | static const yyjson_read_flag | YYJSON_READ_ALLOW_UNQUOTED_KEY = 1 << 13 | | | | static const yyjson_read_flag | YYJSON_READ_JSON5 | | | | static const yyjson_read_code | YYJSON_READ_SUCCESS = 0 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_INVALID_PARAMETER = 1 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_MEMORY_ALLOCATION = 2 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_EMPTY_CONTENT = 3 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_UNEXPECTED_CONTENT = 4 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_UNEXPECTED_END = 5 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_UNEXPECTED_CHARACTER = 6 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_JSON_STRUCTURE = 7 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_INVALID_COMMENT = 8 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_INVALID_NUMBER = 9 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_INVALID_STRING = 10 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_LITERAL = 11 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_FILE_OPEN = 12 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_FILE_READ = 13 | | | | static const yyjson_read_code | YYJSON_READ_ERROR_MORE = 14 | | | | static const yyjson_write_flag | YYJSON_WRITE_NOFLAG = 0 | | | | static const yyjson_write_flag | YYJSON_WRITE_PRETTY = 1 << 0 | | | | static const yyjson_write_flag | YYJSON_WRITE_ESCAPE_UNICODE = 1 << 1 | | | | static const yyjson_write_flag | YYJSON_WRITE_ESCAPE_SLASHES = 1 << 2 | | | | static const yyjson_write_flag | YYJSON_WRITE_ALLOW_INF_AND_NAN = 1 << 3 | | | | static const yyjson_write_flag | YYJSON_WRITE_INF_AND_NAN_AS_NULL = 1 << 4 | | | | static const yyjson_write_flag | YYJSON_WRITE_ALLOW_INVALID_UNICODE = 1 << 5 | | | | static const yyjson_write_flag | YYJSON_WRITE_PRETTY_TWO_SPACES = 1 << 6 | | | | static const yyjson_write_flag | YYJSON_WRITE_NEWLINE_AT_END = 1 << 7 | | | | static const yyjson_write_code | YYJSON_WRITE_SUCCESS = 0 | | | | static const yyjson_write_code | YYJSON_WRITE_ERROR_INVALID_PARAMETER = 1 | | | | static const yyjson_write_code | YYJSON_WRITE_ERROR_MEMORY_ALLOCATION = 2 | | | | static const yyjson_write_code | YYJSON_WRITE_ERROR_INVALID_VALUE_TYPE = 3 | | | | static const yyjson_write_code | YYJSON_WRITE_ERROR_NAN_OR_INF = 4 | | | | static const yyjson_write_code | YYJSON_WRITE_ERROR_FILE_OPEN = 5 | | | | static const yyjson_write_code | YYJSON_WRITE_ERROR_FILE_WRITE = 6 | | | | static const yyjson_write_code | YYJSON_WRITE_ERROR_INVALID_STRING = 7 | | | | static const yyjson_ptr_code | YYJSON_PTR_ERR_NONE = 0 | | | | static const yyjson_ptr_code | YYJSON_PTR_ERR_PARAMETER = 1 | | | | static const yyjson_ptr_code | YYJSON_PTR_ERR_SYNTAX = 2 | | | | static const yyjson_ptr_code | YYJSON_PTR_ERR_RESOLVE = 3 | | | | static const yyjson_ptr_code | YYJSON_PTR_ERR_NULL_ROOT = 4 | | | | static const yyjson_ptr_code | YYJSON_PTR_ERR_SET_ROOT = 5 | | | | static const yyjson_ptr_code | YYJSON_PTR_ERR_MEMORY_ALLOCATION = 6 | | | | static const yyjson_patch_code | YYJSON_PATCH_SUCCESS = 0 | | | | static const yyjson_patch_code | YYJSON_PATCH_ERROR_INVALID_PARAMETER = 1 | | | | static const yyjson_patch_code | YYJSON_PATCH_ERROR_MEMORY_ALLOCATION = 2 | | | | static const yyjson_patch_code | YYJSON_PATCH_ERROR_INVALID_OPERATION = 3 | | | | static const yyjson_patch_code | YYJSON_PATCH_ERROR_MISSING_KEY = 4 | | | | static const yyjson_patch_code | YYJSON_PATCH_ERROR_INVALID_MEMBER = 5 | | | | static const yyjson_patch_code | YYJSON_PATCH_ERROR_EQUAL = 6 | | | | static const yyjson_patch_code | YYJSON_PATCH_ERROR_POINTER = 7 | | |
Date2019-03-09 AuthorYaoYuan
| struct yyjson_alc |
A memory allocator.
Typically you don't need to use it, unless you want to customize your own memory allocator.
| Data Fields |
|---|
| void *(*)(void *ctx, size_t size) |
Same as libc's malloc(size), should not be NULL.
| | void *(*)(void *ctx, void *ptr, size_t old_size, size_t size) | realloc |
Same as libc's realloc(ptr, size), should not be NULL.
| | void(*)(void *ctx, void *ptr) | free |
Same as libc's free(ptr), should not be NULL.
| | void * | ctx |
A context for malloc/realloc/free, can be NULL.
|
| struct yyjson_read_err |
Error information for JSON reader.
| Data Fields |
|---|
| yyjson_read_code |
Error code, see yyjson_read_code for all possible values.
| | const char * | msg |
Error message, constant, no need to free (NULL if success).
| | size_t | pos |
Error byte position for input data (0 if success).
|
| struct yyjson_write_err |
Error information for JSON writer.
| Data Fields |
|---|
| yyjson_write_code |
Error code, see yyjson_write_code for all possible values.
| | const char * | msg |
Error message, constant, no need to free (NULL if success).
|
| struct yyjson_arr_iter |
A JSON array iterator.
Example
yyjson_val *val;
[yyjson_arr_iter](#structyyjson arr iter) iter = yyjson_arr_iter_with(arr);
while ((val = yyjson_arr_iter_next(&iter))) {
your_func(val);
}
yyjson_api_inline yyjson_arr_iter yyjson_arr_iter_with(yyjson_val *arr)
Definition yyjson.h:5452
yyjson_api_inline yyjson_val * yyjson_arr_iter_next(yyjson_arr_iter *iter)
Definition yyjson.h:5462
[yyjson_arr_iter](#structyyjson arr iter)
Definition yyjson.h:1990
Definition yyjson.h:4765
| Data Fields |
|---|
| size_t |
next value's index
| | size_t | max |
maximum index (arr.size)
| | yyjson_val * | cur |
next value
|
| struct yyjson_obj_iter |
A JSON object iterator.
Example
yyjson_val *key, *val;
[yyjson_obj_iter](#structyyjson obj iter) iter = yyjson_obj_iter_with(obj);
while ((key = yyjson_obj_iter_next(&iter))) {
val = yyjson_obj_iter_get_val(key);
your_func(key, val);
}
yyjson_api_inline yyjson_val * yyjson_obj_iter_get_val(yyjson_val *key)
Definition yyjson.h:5541
yyjson_api_inline yyjson_obj_iter yyjson_obj_iter_with(yyjson_val *obj)
Definition yyjson.h:5521
yyjson_api_inline yyjson_val * yyjson_obj_iter_next(yyjson_obj_iter *iter)
Definition yyjson.h:5531
yyjson_val * obj
Definition yyjson.h:2118
[yyjson_obj_iter](#structyyjson obj iter)
Definition yyjson.h:2114
If the ordering of the keys is known at compile-time, you can use this method to speed up value lookups:
// {"k1":1, "k2": 3, "k3": 3}
yyjson_val *key, *val;
[yyjson_obj_iter](#structyyjson obj iter) iter = yyjson_obj_iter_with(obj);
yyjson_val *v1 = yyjson_obj_iter_get(&iter, "k1");
yyjson_val *v3 = yyjson_obj_iter_get(&iter, "k3");
yyjson_api_inline yyjson_val * yyjson_obj_iter_get(yyjson_obj_iter *iter, const char *key)
Definition yyjson.h:5545
See alsoyyjson_obj_iter_get() and yyjson_obj_iter_getn()
| Data Fields |
|---|
| size_t |
next key's index
| | size_t | max |
maximum key index (obj.size)
| | yyjson_val * | cur |
next key
| | yyjson_val * | obj |
the object being iterated
|
| struct yyjson_mut_arr_iter |
A mutable JSON array iterator.
WarningYou should not modify the array while iterating over it, but you can use yyjson_mut_arr_iter_remove() to remove current value.
Example
[yyjson_mut_val](#structyyjson mut val) *val;
[yyjson_mut_arr_iter](#structyyjson mut arr__iter) iter = yyjson_mut_arr_iter_with(arr);
while ((val = yyjson_mut_arr_iter_next(&iter))) {
your_func(val);
if (your_val_is_unused(val)) {
yyjson_mut_arr_iter_remove(&iter);
}
}
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_iter_remove(yyjson_mut_arr_iter *iter)
Definition yyjson.h:6171
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_iter_next(yyjson_mut_arr_iter *iter)
Definition yyjson.h:6159
yyjson_api_inline yyjson_mut_arr_iter yyjson_mut_arr_iter_with(yyjson_mut_val *arr)
Definition yyjson.h:6148
yyjson_mut_val * arr
Definition yyjson.h:2716
[yyjson_mut_arr_iter](#structyyjson mut arr__iter)
Definition yyjson.h:2711
[yyjson_mut_val](#structyyjson mut val)
Definition yyjson.h:5590
| Data Fields |
|---|
| size_t |
next value's index
| | size_t | max |
maximum index (arr.size)
| | [yyjson_mut_val](#structyyjson mut val) * | cur |
current value
| | [yyjson_mut_val](#structyyjson mut val) * | pre |
previous value
| | [yyjson_mut_val](#structyyjson mut val) * | arr |
the array being iterated
|
| struct yyjson_mut_obj_iter |
A mutable JSON object iterator.
WarningYou should not modify the object while iterating over it, but you can use yyjson_mut_obj_iter_remove() to remove current value.
Example
[yyjson_mut_val](#structyyjson mut val) *key, *val;
[yyjson_mut_obj_iter](#structyyjson mut obj__iter) iter = yyjson_mut_obj_iter_with(obj);
while ((key = yyjson_mut_obj_iter_next(&iter))) {
val = yyjson_mut_obj_iter_get_val(key);
your_func(key, val);
if (your_val_is_unused(key, val)) {
yyjson_mut_obj_iter_remove(&iter);
}
}
yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_next(yyjson_mut_obj_iter *iter)
Definition yyjson.h:6804
yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_remove(yyjson_mut_obj_iter *iter)
Definition yyjson.h:6821
yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_get_val(yyjson_mut_val *key)
Definition yyjson.h:6816
yyjson_mut_val * obj
Definition yyjson.h:3542
yyjson_api_inline yyjson_mut_obj_iter yyjson_mut_obj_iter_with(yyjson_mut_val *obj)
Definition yyjson.h:6793
[yyjson_mut_obj_iter](#structyyjson mut obj__iter)
Definition yyjson.h:3537
If the ordering of the keys is known at compile-time, you can use this method to speed up value lookups:
// {"k1":1, "k2": 3, "k3": 3}
[yyjson_mut_val](#structyyjson mut val) *key, *val;
[yyjson_mut_obj_iter](#structyyjson mut obj__iter) iter = yyjson_mut_obj_iter_with(obj);
[yyjson_mut_val](#structyyjson mut val) *v1 = yyjson_mut_obj_iter_get(&iter, "k1");
[yyjson_mut_val](#structyyjson mut val) *v3 = yyjson_mut_obj_iter_get(&iter, "k3");
yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_get(yyjson_mut_obj_iter *iter, const char *key)
Definition yyjson.h:6838
See alsoyyjson_mut_obj_iter_get() and yyjson_mut_obj_iter_getn()
| Data Fields |
|---|
| size_t |
next key's index
| | size_t | max |
maximum key index (obj.size)
| | [yyjson_mut_val](#structyyjson mut val) * | cur |
current key
| | [yyjson_mut_val](#structyyjson mut val) * | pre |
previous key
| | [yyjson_mut_val](#structyyjson mut val) * | obj |
the object being iterated
|
| struct yyjson_ptr_err |
Error information for JSON pointer.
| Data Fields |
|---|
| yyjson_ptr_code |
Error code, see yyjson_ptr_code for all possible values.
| | const char * | msg |
Error message, constant, no need to free (NULL if no error).
| | size_t | pos |
Error byte position for input JSON pointer (0 if no error).
|
| struct yyjson_ptr_ctx |
A context for JSON pointer operation.
This struct stores the context of JSON Pointer operation result. The struct can be used with three helper functions: ctx_append(), ctx_replace(), and ctx_remove(), which perform the corresponding operations on the container without re-parsing the JSON Pointer.
For example:
// doc before: {"a":[0,1,null]}
// ptr: "/a/2"
val = yyjson_mut_doc_ptr_getx(doc, ptr, strlen(ptr), &ctx, &err);
if (yyjson_is_null(val)) {
yyjson_ptr_ctx_remove(&ctx);
}
// doc after: {"a":[0,1]}
yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_getx(yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
Definition yyjson.h:7485
yyjson_api_inline bool yyjson_is_null(yyjson_val *val)
Definition yyjson.h:5149
yyjson_api_inline bool yyjson_ptr_ctx_remove(yyjson_ptr_ctx *ctx)
Definition yyjson.h:7991
| Data Fields |
|---|
| [yyjson_mut_val](#structyyjson mut val) * |
The container (parent) of the target value. It can be either an array or an object. If the target location has no value, but all its parent containers exist, and the target location can be used to insert a new value, then ctn is the parent container of the target location. Otherwise, ctn is NULL.
| | [yyjson_mut_val](#structyyjson mut val) * | pre |
The previous sibling of the target value. It can be either a value in an array or a key in an object. As the container is a circular linked list of elements, pre is the previous node of the target value. If the operation is add or set, then pre is the previous node of the new value, not the original target value. If the target value does not exist, pre is NULL.
| | [yyjson_mut_val](#structyyjson mut val) * | old |
The removed value if the operation is set, replace or remove. It can be used to restore the original state of the document if needed.
|
| struct yyjson_patch_err |
Error information for JSON patch.
| Data Fields |
|---|
| yyjson_patch_code |
Error code, see yyjson_patch_code for all possible values.
| | size_t | idx |
Index of the error operation (0 if no error).
| | const char * | msg |
Error message, constant, no need to free (NULL if no error).
| | [yyjson_ptr_err](#structyyjson ptr err) | ptr |
JSON pointer error if code == YYJSON_PATCH_ERROR_POINTER.
|
| union yyjson_val_uni |
Payload of a JSON value (8 bytes).
| struct yyjson_val |
Immutable JSON value, 16 bytes.
An immutable value for reading JSON. A JSON Value has the same lifetime as its document. The memory is held by its document and and cannot be freed alone.
| Data Fields |
|---|
| uint64_t |
type, subtype and length
| | [yyjson_val_uni](#unionyyjson val uni) | uni |
payload
|
| struct yyjson_doc |
An immutable document for reading JSON. This document holds memory for all its JSON values and strings. When it is no longer used, the user should call yyjson_doc_free() to free its memory.
| Data Fields |
|---|
| yyjson_val * |
Root value of the document (nonnull).
| | yyjson_alc | alc |
Allocator used by document (nonnull).
| | size_t | dat_read |
The total number of bytes read when parsing JSON (nonzero).
| | size_t | val_read |
The total number of value read when parsing JSON (nonzero).
| | char * | str_pool |
The string pool used by JSON values (nullable).
|
| struct yyjson_mut_val |
Mutable JSON value, 24 bytes. The 'tag' and 'uni' field is same as immutable value. The 'next' field links all elements inside the container to be a cycle.
A mutable value for building JSON. A JSON Value has the same lifetime as its document. The memory is held by its document and and cannot be freed alone.
| Data Fields |
|---|
| uint64_t |
type, subtype and length
| | [yyjson_val_uni](#unionyyjson val uni) | uni |
payload
| | [yyjson_mut_val](#structyyjson mut val) * | next |
the next value in circular linked list
|
| struct yyjson_str_chunk |
A memory chunk in string memory pool.
| struct yyjson_str_pool |
A memory pool to hold all strings in a mutable document.
| struct yyjson_val_chunk |
A memory chunk in value memory pool. sizeof(yyjson_val_chunk) should not larger than sizeof(yyjson_mut_val).
| struct yyjson_val_pool |
A memory pool to hold all values in a mutable document.
| struct yyjson_mut_doc |
A mutable document for building JSON. This document holds memory for all its JSON values and strings. When it is no longer used, the user should call yyjson_mut_doc_free() to free its memory.
| Data Fields |
|---|
| [yyjson_mut_val](#structyyjson mut val) * |
root value of the JSON document, nullable
| | yyjson_alc | alc |
a valid allocator, nonnull
| | [yyjson_str_pool](#structyyjson str pool) | str_pool |
string memory pool
| | [yyjson_val_pool](#structyyjson val pool) | val_pool |
value memory pool
|
| #define YYJSON_MSC_VER 0 |
compiler version (MSVC)
| #define YYJSON_GCC_VER 0 |
compiler version (GCC)
| #define YYJSON_IS_REAL_GCC 0 |
real gcc check
| #define YYJSON_STDC_VER 0 |
C version (STDC)
| #define YYJSON_CPP_VER 0 |
C++ version
| #define yyjson_has_builtin | ( | | x | ) | |
Value:
0
compiler builtin check (since gcc 10.0, clang 2.6, icc 2021)
| #define yyjson_has_attribute | ( | | x | ) | |
Value:
0
compiler attribute check (since gcc 5.0, clang 2.9, icc 17)
| #define yyjson_has_feature | ( | | x | ) | |
Value:
0
compiler feature check (since clang 2.6, icc 17)
| #define yyjson_has_include | ( | | x | ) | |
Value:
0
include check (since gcc 5.0, clang 2.7, icc 16, msvc 2017 15.3)
| #define yyjson_inline |
inline for compiler
| #define yyjson_noinline |
noinline for compiler
| #define yyjson_align | ( | | x | ) | |
align for compiler
| #define yyjson_likely | ( | | expr | ) | |
Value:
(expr)
likely for compiler
| #define yyjson_unlikely | ( | | expr | ) | |
Value:
(expr)
unlikely for compiler
| #define YYJSON_HAS_CONSTANT_P 0 |
compile-time constant check for compiler
| #define yyjson_deprecated | ( | | msg | ) | |
deprecate warning
| #define yyjson_api |
function export
| #define yyjson_api_inline static yyjson_inline |
inline function export
| #define __bool_true_false_are_defined 1 |
stdint (C89 compatible) stdbool (C89 compatible)
| #define YYJSON_U64_TO_F64_NO_IMPL 0 |
char bit check Microsoft Visual C++ 6.0 doesn't support converting number from u64 to f64: error C2520: conversion from unsigned __int64 to double not implemented.
| #define YYJSON_VERSION_MAJOR 0 |
The major version of yyjson.
| #define YYJSON_VERSION_MINOR 12 |
The minor version of yyjson.
| #define YYJSON_VERSION_PATCH 0 |
The patch version of yyjson.
| #define YYJSON_VERSION_HEX 0x000C00 |
The version of yyjson in hex: (major << 16) | (minor << 8) | (patch).
| #define YYJSON_VERSION_STRING "0.12.0" |
The version string of yyjson.
| #define YYJSON_TYPE_NONE ((uint8_t)0) /* _____000 */ |
No type, invalid.
| #define YYJSON_TYPE_RAW ((uint8_t)1) /* _____001 */ |
Raw string type, no subtype.
| #define YYJSON_TYPE_NULL ((uint8_t)2) /* _____010 */ |
Null type: null literal, no subtype.
| #define YYJSON_TYPE_BOOL ((uint8_t)3) /* _____011 */ |
Boolean type, subtype: TRUE, FALSE.
| #define YYJSON_TYPE_NUM ((uint8_t)4) /* _____100 */ |
Number type, subtype: UINT, SINT, REAL.
| #define YYJSON_TYPE_STR ((uint8_t)5) /* _____101 */ |
String type, subtype: NONE, NOESC.
| #define YYJSON_TYPE_ARR ((uint8_t)6) /* _____110 */ |
Array type, no subtype.
| #define YYJSON_TYPE_OBJ ((uint8_t)7) /* _____111 */ |
Object type, no subtype.
| #define YYJSON_SUBTYPE_NONE ((uint8_t)(0 << 3)) /* ___00___ */ |
No subtype.
| #define YYJSON_SUBTYPE_FALSE ((uint8_t)(0 << 3)) /* ___00___ */ |
False subtype: false literal.
| #define YYJSON_SUBTYPE_TRUE ((uint8_t)(1 << 3)) /* ___01___ */ |
True subtype: true literal.
| #define YYJSON_SUBTYPE_UINT ((uint8_t)(0 << 3)) /* ___00___ */ |
Unsigned integer subtype: uint64_t.
| #define YYJSON_SUBTYPE_SINT ((uint8_t)(1 << 3)) /* ___01___ */ |
Signed integer subtype: int64_t.
| #define YYJSON_SUBTYPE_REAL ((uint8_t)(2 << 3)) /* ___10___ */ |
Real number subtype: double.
| #define YYJSON_SUBTYPE_NOESC ((uint8_t)(1 << 3)) /* ___01___ */ |
String that do not need to be escaped for writing (internal use).
| #define YYJSON_TYPE_MASK ((uint8_t)0x07) /* _____111 */ |
The mask used to extract the type of a JSON value.
| #define YYJSON_TYPE_BIT ((uint8_t)3) |
The number of bits used by the type.
| #define YYJSON_SUBTYPE_MASK ((uint8_t)0x18) /* ___11___ */ |
The mask used to extract the subtype of a JSON value.
| #define YYJSON_SUBTYPE_BIT ((uint8_t)2) |
The number of bits used by the subtype.
| #define YYJSON_RESERVED_MASK ((uint8_t)0xE0) /* 111_____ */ |
The mask used to extract the reserved bits of a JSON value.
| #define YYJSON_RESERVED_BIT ((uint8_t)3) |
The number of reserved bits.
| #define YYJSON_TAG_MASK ((uint8_t)0xFF) /* 11111111 */ |
The mask used to extract the tag of a JSON value.
| #define YYJSON_TAG_BIT ((uint8_t)8) |
The number of bits used by the tag.
| #define YYJSON_PADDING_SIZE 4 |
Padding size for JSON reader.
| #define YYJSON_WRITE_FP_FLAG_BITS 8 |
The highest 8 bits of yyjson_write_flag and real number value's tag are reserved for controlling the output format of floating-point numbers.
| #define YYJSON_WRITE_FP_PREC_BITS 4 |
The highest 4 bits of flag are reserved for precision value.
| #define YYJSON_WRITE_FP_TO_FIXED | ( | | prec | ) | |
Value:
((yyjson_write_flag)( \
(uint32_t)((uint32_t)(prec)) << (32 - 4) ))
uint32_t yyjson_write_flag
Definition yyjson.h:1155
Write floating-point number using fixed-point notation.
Number.prototype.toFixed(prec), but with trailing zeros removed. The prec ranges from 1 to 15.| #define YYJSON_WRITE_FP_TO_FLOAT ((yyjson_write_flag)(1 << (32 - 5))) |
Write floating-point numbers using single-precision (float).
double to float before serialization.YYJSON_WRITE_FP_TO_FIXED(prec) is also used.| #define yyjson_arr_foreach | ( | | arr, | | | | | idx, | | | | | max, | | | | | val ) |
Value:
for ((idx) = 0, \
(max) = yyjson_arr_size(arr), \
(val) = yyjson_arr_get_first(arr); \
(idx) < (max); \
(idx)++, \
(val) = unsafe_yyjson_get_next(val))
yyjson_api_inline size_t yyjson_arr_size(yyjson_val *arr)
Definition yyjson.h:5390
yyjson_api_inline yyjson_val * yyjson_arr_get_first(yyjson_val *arr)
Definition yyjson.h:5409
Macro for iterating over an array. It works like iterator, but with a more intuitive API.
Example
size_t idx, max;
yyjson_val *val;
yyjson_arr_foreach(arr, idx, max, val) {
your_func(idx, val);
}
#define yyjson_arr_foreach(arr, idx, max, val)
Definition yyjson.h:2046
| #define yyjson_obj_foreach | ( | | obj, | | | | | idx, | | | | | max, | | | | | key, | | | | | val ) |
Value:
for ((idx) = 0, \
(max) = yyjson_obj_size(obj), \
(key) = (obj) ? unsafe_yyjson_get_first(obj) : NULL, \
(val) = (key) + 1; \
(idx) < (max); \
(idx)++, \
(key) = unsafe_yyjson_get_next(val), \
(val) = (key) + 1)
yyjson_api_inline size_t yyjson_obj_size(yyjson_val *obj)
Definition yyjson.h:5479
Macro for iterating over an object. It works like iterator, but with a more intuitive API.
Example
size_t idx, max;
yyjson_val *key, *val;
yyjson_obj_foreach(obj, idx, max, key, val) {
your_func(key, val);
}
#define yyjson_obj_foreach(obj, idx, max, key, val)
Definition yyjson.h:2217
| #define yyjson_mut_arr_foreach | ( | | arr, | | | | | idx, | | | | | max, | | | | | val ) |
Value:
for ((idx) = 0, \
(max) = yyjson_mut_arr_size(arr), \
(val) = yyjson_mut_arr_get_first(arr); \
(idx) < (max); \
(idx)++, \
(val) = (val)->next)
yyjson_mut_val * next
Definition yyjson.h:5593
yyjson_api_inline size_t yyjson_mut_arr_size(yyjson_mut_val *arr)
Definition yyjson.h:6098
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_get_first(yyjson_mut_val *arr)
Definition yyjson.h:6112
Macro for iterating over an array. It works like iterator, but with a more intuitive API.
WarningYou should not modify the array while iterating over it.
Example
size_t idx, max;
[yyjson_mut_val](#structyyjson mut val) *val;
yyjson_mut_arr_foreach(arr, idx, max, val) {
your_func(idx, val);
}
#define yyjson_mut_arr_foreach(arr, idx, max, val)
Definition yyjson.h:2781
| #define yyjson_mut_obj_foreach | ( | | obj, | | | | | idx, | | | | | max, | | | | | key, | | | | | val ) |
Value:
for ((idx) = 0, \
(max) = yyjson_mut_obj_size(obj), \
(key) = (max) ? (([yyjson_mut_val](#structyyjson mut val) *)(obj)->uni.ptr)->next->next : NULL, \
(val) = (key) ? (key)->next : NULL; \
(idx) < (max); \
(idx)++, \
(key) = (val)->next, \
(val) = (key)->next)
yyjson_api_inline size_t yyjson_mut_obj_size(yyjson_mut_val *obj)
Definition yyjson.h:6750
Macro for iterating over an object. It works like iterator, but with a more intuitive API.
WarningYou should not modify the object while iterating over it.
Example
size_t idx, max;
[yyjson_mut_val](#structyyjson mut val) *key, *val;
yyjson_mut_obj_foreach(obj, idx, max, key, val) {
your_func(key, val);
}
#define yyjson_mut_obj_foreach(obj, idx, max, key, val)
Definition yyjson.h:3653
| typedef uint8_t yyjson_type |
Type of a JSON value (3 bit).
| typedef uint8_t yyjson_subtype |
Subtype of a JSON value (2 bit).
| typedef uint32_t yyjson_read_flag |
Run-time options for JSON reader.
| typedef uint32_t yyjson_read_code |
Result code for JSON reader.
| typedef struct yyjson_incr_state yyjson_incr_state |
Opaque state for incremental JSON reader.
| typedef uint32_t yyjson_write_flag |
Run-time options for JSON writer.
| typedef uint32_t yyjson_write_code |
Result code for JSON writer
| typedef uint32_t yyjson_ptr_code |
JSON Pointer error code.
| typedef uint32_t yyjson_patch_code |
Result code for JSON patch.
| yyjson_api uint32_t yyjson_version | ( | void | | ) | |
The version of yyjson in hex, same as YYJSON_VERSION_HEX.
| yyjson_api bool yyjson_alc_pool_init | ( | yyjson_alc * | alc, | | | | void * | buf, | | | | size_t | size ) |
A pool allocator uses fixed length pre-allocated memory.
This allocator may be used to avoid malloc/realloc calls. The pre-allocated memory should be held by the caller. The maximum amount of memory required to read a JSON can be calculated using the yyjson_read_max_memory_usage() function, but the amount of memory required to write a JSON cannot be directly calculated.
This is not a general-purpose allocator. It is designed to handle a single JSON data at a time. If it is used for overly complex memory tasks, such as parsing multiple JSON documents using the same allocator but releasing only a few of them, it may cause memory fragmentation, resulting in performance degradation and memory waste.
Parameters
| alc | The allocator to be initialized. If this parameter is NULL, the function will fail and return false. If buf or size is invalid, this will be set to an empty allocator. |
| buf | The buffer memory for this allocator. If this parameter is NULL, the function will fail and return false. |
| size | The size of buf, in bytes. If this parameter is less than 8 words (32/64 bytes on 32/64-bit OS), the function will fail and return false. |
Returnstrue if the alc has been successfully initialized.
Example
// parse JSON with stack memory
char buf[1024];
yyjson_alc alc;
yyjson_alc_pool_init(&alc, buf, 1024);
const char *json = "{"name":"Helvetica","size":16}"
yyjson_doc *doc = yyjson_read_opts(json, strlen(json), 0, &alc, NULL);
// the memory of doc is on the stack
yyjson_api bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, size_t size)
yyjson_api yyjson_doc * yyjson_read_opts(char *dat, size_t len, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)
Definition yyjson.h:586
Definition yyjson.h:4770
WarningThis Allocator is not thread-safe.
| yyjson_api yyjson_alc * yyjson_alc_dyn_new | ( | void | | ) | |
A dynamic allocator.
This allocator has a similar usage to the pool allocator above. However, when there is not enough memory, this allocator will dynamically request more memory using libc's malloc function, and frees it all at once when it is destroyed.
ReturnsA new dynamic allocator, or NULL if memory allocation failed. NoteThe returned value should be freed with yyjson_alc_dyn_free().WarningThis Allocator is not thread-safe.
| yyjson_api void yyjson_alc_dyn_free | ( | yyjson_alc * | alc | ) | |
Free a dynamic allocator which is created by yyjson_alc_dyn_new().
Parameters
| alc | The dynamic allocator to be destroyed. |
| yyjson_api bool yyjson_locate_pos | ( | const char * | str, | | | | size_t | len, | | | | size_t | pos, | | | | size_t * | line, | | | | size_t * | col, | | | | size_t * | chr ) |
Locate the line and column number for a byte position in a string. This can be used to get better description for error position.
Parameters
| str | The input string. | | len | The byte length of the input string. | | pos | The byte position within the input string. | | line | A pointer to receive the line number, starting from 1. | | col | A pointer to receive the column number, starting from 1. | | chr | A pointer to receive the character index, starting from 0. |
Returnstrue on success, false if str is NULL or pos is out of bounds. NoteLine/column/character are calculated based on Unicode characters for compatibility with text editors. For multi-byte UTF-8 characters, the returned value may not directly correspond to the byte position.
| yyjson_api yyjson_doc * yyjson_read_opts | ( | char * | dat, | | | | size_t | len, | | | | yyjson_read_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_read_err](#structyyjson read err) * | err ) |
Read JSON with options.
This function is thread-safe when:
dat is not modified by other threads.alc is thread-safe or NULL.Parameters
| dat | The JSON data (UTF-8 without BOM), null-terminator is not required. If this parameter is NULL, the function will fail and return NULL. The dat will not be modified without the flag YYJSON_READ_INSITU, so you can pass a const char * string and case it to char * if you don't use the YYJSON_READ_INSITU flag. |
| len | The length of JSON data in bytes. If this parameter is 0, the function will fail and return NULL. |
| flg | The JSON read options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON reader. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ReturnsA new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with yyjson_doc_free().
| yyjson_api yyjson_doc * yyjson_read_file | ( | const char * | path, | | | | yyjson_read_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_read_err](#structyyjson read err) * | err ) |
Read a JSON file.
This function is thread-safe when:
alc is thread-safe or NULL.Parameters
| path | The JSON file's path. This should be a null-terminated string using the system's native encoding. If this path is NULL or invalid, the function will fail and return NULL. |
| flg | The JSON read options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON reader. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ReturnsA new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with yyjson_doc_free().WarningOn 32-bit operating system, files larger than 2GB may fail to read.
| yyjson_api yyjson_doc * yyjson_read_fp | ( | FILE * | fp, | | | | yyjson_read_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_read_err](#structyyjson read err) * | err ) |
Read JSON from a file pointer.
Parameters
| fp | The file pointer. The data will be read from the current position of the FILE to the end. If this fp is NULL or invalid, the function will fail and return NULL. |
| flg | The JSON read options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON reader. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ReturnsA new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with yyjson_doc_free().WarningOn 32-bit operating system, files larger than 2GB may fail to read.
| yyjson_api_inline yyjson_doc * yyjson_read | ( | const char * | dat, | | | | size_t | len, | | | | yyjson_read_flag | flg ) |
Read a JSON string.
This function is thread-safe.
Parameters
| dat | The JSON data (UTF-8 without BOM), null-terminator is not required. If this parameter is NULL, the function will fail and return NULL. |
| len | The length of JSON data in bytes. If this parameter is 0, the function will fail and return NULL. |
| flg | The JSON read options. Multiple options can be combined with | operator. 0 means no options. |
ReturnsA new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with yyjson_doc_free().
| yyjson_api yyjson_incr_state * yyjson_incr_new | ( | char * | buf, | | | | size_t | buf_len, | | | | yyjson_read_flag | flg, | | | | const yyjson_alc * | alc ) |
Initialize state for incremental read.
To read a large JSON document incrementally:
yyjson_incr_new() to create the state for incremental reading.yyjson_incr_read() repeatedly.yyjson_incr_free() to free the state.Note: The incremental JSON reader only supports standard JSON. Flags for non-standard features (e.g. comments, trailing commas) are ignored.
Parameters
| buf | The JSON data, null-terminator is not required. If this parameter is NULL, the function will fail and return NULL. |
| buf_len | The length of the JSON data in buf. If use YYJSON_READ_INSITU, buf_len should not include the padding size. |
| flg | The JSON read options. Multiple options can be combined with | operator. |
| alc | The memory allocator used by JSON reader. Pass NULL to use the libc's default allocator. |
ReturnsA state for incremental reading. It should be freed with yyjson_incr_free(). NULL is returned if memory allocation fails.
| yyjson_api yyjson_doc * yyjson_incr_read | ( | yyjson_incr_state * | state, | | | | size_t | len, | | | | [yyjson_read_err](#structyyjson read err) * | err ) |
Performs incremental read of up to len bytes.
If NULL is returned and err->code is set to YYJSON_READ_ERROR_MORE, it indicates that more data is required to continue parsing. Then, call this function again with incremented len. Continue until a document is returned or an error other than YYJSON_READ_ERROR_MORE is returned.
Note: Parsing in very small increments is not efficient. An increment of several kilobytes or megabytes is recommended.
Parameters
| state | The state for incremental reading, created using yyjson_incr_new(). |
| len | The number of bytes of JSON data available to parse. If this parameter is 0, the function will fail and return NULL. |
| err | A pointer to receive error information. |
ReturnsA new JSON document, or NULL if an error occurs. When the document is no longer needed, it should be freed with yyjson_doc_free().
| yyjson_api void yyjson_incr_free | ( | yyjson_incr_state * | state | ) | |
Release the incremental read state and free the memory.
| yyjson_api_inline size_t yyjson_read_max_memory_usage | ( | size_t | len, | | | | yyjson_read_flag | flg ) |
Returns the size of maximum memory usage to read a JSON data.
You may use this value to avoid malloc() or calloc() call inside the reader to get better performance, or read multiple JSON with one piece of memory.
Parameters
| len | The length of JSON data in bytes. | | flg | The JSON read options. |
ReturnsThe maximum memory size to read this JSON, or 0 if overflow.
Example
// read multiple JSON with same pre-allocated memory
char *dat1, *dat2, *dat3; // JSON data
size_t len1, len2, len3; // JSON length
size_t max_len = MAX(len1, MAX(len2, len3));
yyjson_doc *doc;
// use one allocator for multiple JSON
size_t size = yyjson_read_max_memory_usage(max_len, 0);
void *buf = malloc(size);
yyjson_alc alc;
yyjson_alc_pool_init(&alc, buf, size);
// no more alloc() or realloc() call during reading
doc = yyjson_read_opts(dat1, len1, 0, &alc, NULL);
yyjson_doc_free(doc);
doc = yyjson_read_opts(dat2, len2, 0, &alc, NULL);
yyjson_doc_free(doc);
doc = yyjson_read_opts(dat3, len3, 0, &alc, NULL);
yyjson_doc_free(doc);
free(buf);
yyjson_api_inline void yyjson_doc_free(yyjson_doc *doc)
Definition yyjson.h:5130
yyjson_api_inline size_t yyjson_read_max_memory_usage(size_t len, yyjson_read_flag flg)
Definition yyjson.h:1090
See alsoyyjson_alc_pool_init()
| yyjson_api const char * yyjson_read_number | ( | const char * | dat, | | | | yyjson_val * | val, | | | | yyjson_read_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_read_err](#structyyjson read err) * | err ) |
Read a JSON number.
This function is thread-safe when data is not modified by other threads.
Parameters
| dat | The JSON data (UTF-8 without BOM), null-terminator is required. If this parameter is NULL, the function will fail and return NULL. |
| val | The output value where result is stored. If this parameter is NULL, the function will fail and return NULL. The value will hold either UINT or SINT or REAL number; |
| flg | The JSON read options. Multiple options can be combined with | operator. 0 means no options. Supports YYJSON_READ_NUMBER_AS_RAW and YYJSON_READ_ALLOW_INF_AND_NAN. |
| alc | The memory allocator used for long number. It is only used when the built-in floating point reader is disabled. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ReturnsIf successful, a pointer to the character after the last character used in the conversion, NULL if an error occurs.
| yyjson_api_inline const char * yyjson_mut_read_number | ( | const char * | dat, | | | | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | yyjson_read_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_read_err](#structyyjson read err) * | err ) |
Same as yyjson_read_number().
| yyjson_api char * yyjson_write_opts | ( | const yyjson_doc * | doc, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | size_t * | len, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a document to JSON string with options.
This function is thread-safe when: The alc is thread-safe or NULL.
Parameters
| doc | The JSON document. If this doc is NULL or has no root, the function will fail and return false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ReturnsA new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free().
| yyjson_api bool yyjson_write_file | ( | const char * | path, | | | | const yyjson_doc * | doc, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a document to JSON file with options.
This function is thread-safe when:
alc is thread-safe or NULL.Parameters
| path | The JSON file's path. This should be a null-terminated string using the system's native encoding. If this path is NULL or invalid, the function will fail and return false. If this file is not empty, the content will be discarded. |
| doc | The JSON document. If this doc is NULL or has no root, the function will fail and return false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Returnstrue if successful, false if an error occurs.WarningOn 32-bit operating system, files larger than 2GB may fail to write.
| yyjson_api bool yyjson_write_fp | ( | FILE * | fp, | | | | const yyjson_doc * | doc, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a document to file pointer with options.
Parameters
| fp | The file pointer. The data will be written to the current position of the file. If this fp is NULL or invalid, the function will fail and return false. |
| doc | The JSON document. If this doc is NULL or has no root, the function will fail and return false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Returnstrue if successful, false if an error occurs.WarningOn 32-bit operating system, files larger than 2GB may fail to write.
| yyjson_api_inline char * yyjson_write | ( | const yyjson_doc * | doc, | | | | yyjson_write_flag | flg, | | | | size_t * | len ) |
Write a document to JSON string.
This function is thread-safe.
Parameters
| doc | The JSON document. If this doc is NULL or has no root, the function will fail and return false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
ReturnsA new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free().
| yyjson_api char * yyjson_mut_write_opts | ( | const [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | size_t * | len, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a document to JSON string with options.
This function is thread-safe when:
doc is not modified by other threads.alc is thread-safe or NULL.Parameters
| doc | The mutable JSON document. If this doc is NULL or has no root, the function will fail and return false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ReturnsA new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free().
| yyjson_api bool yyjson_mut_write_file | ( | const char * | path, | | | | const [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a document to JSON file with options.
This function is thread-safe when:
doc is not modified by other threads.alc is thread-safe or NULL.Parameters
| path | The JSON file's path. This should be a null-terminated string using the system's native encoding. If this path is NULL or invalid, the function will fail and return false. If this file is not empty, the content will be discarded. |
| doc | The mutable JSON document. If this doc is NULL or has no root, the function will fail and return false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Returnstrue if successful, false if an error occurs.WarningOn 32-bit operating system, files larger than 2GB may fail to write.
| yyjson_api bool yyjson_mut_write_fp | ( | FILE * | fp, | | | | const [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a document to file pointer with options.
Parameters
| fp | The file pointer. The data will be written to the current position of the file. If this fp is NULL or invalid, the function will fail and return false. |
| doc | The mutable JSON document. If this doc is NULL or has no root, the function will fail and return false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Returnstrue if successful, false if an error occurs.WarningOn 32-bit operating system, files larger than 2GB may fail to write.
| yyjson_api_inline char * yyjson_mut_write | ( | const [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | yyjson_write_flag | flg, | | | | size_t * | len ) |
Write a document to JSON string.
This function is thread-safe when: The doc is not modified by other threads.
Parameters
| doc | The JSON document. If this doc is NULL or has no root, the function will fail and return false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
ReturnsA new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free().
| yyjson_api char * yyjson_val_write_opts | ( | const yyjson_val * | val, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | size_t * | len, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a value to JSON string with options.
This function is thread-safe when: The alc is thread-safe or NULL.
Parameters
| val | The JSON root value. If this parameter is NULL, the function will fail and return NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ReturnsA new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free().
| yyjson_api bool yyjson_val_write_file | ( | const char * | path, | | | | const yyjson_val * | val, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a value to JSON file with options.
This function is thread-safe when:
alc is thread-safe or NULL.Parameters
| path | The JSON file's path. This should be a null-terminated string using the system's native encoding. If this path is NULL or invalid, the function will fail and return false. If this file is not empty, the content will be discarded. |
| val | The JSON root value. If this parameter is NULL, the function will fail and return NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Returnstrue if successful, false if an error occurs.WarningOn 32-bit operating system, files larger than 2GB may fail to write.
| yyjson_api bool yyjson_val_write_fp | ( | FILE * | fp, | | | | const yyjson_val * | val, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a value to file pointer with options.
Parameters
| fp | The file pointer. The data will be written to the current position of the file. If this path is NULL or invalid, the function will fail and return false. |
| val | The JSON root value. If this parameter is NULL, the function will fail and return NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Returnstrue if successful, false if an error occurs.WarningOn 32-bit operating system, files larger than 2GB may fail to write.
| yyjson_api_inline char * yyjson_val_write | ( | const yyjson_val * | val, | | | | yyjson_write_flag | flg, | | | | size_t * | len ) |
Write a value to JSON string.
This function is thread-safe.
Parameters
| val | The JSON root value. If this parameter is NULL, the function will fail and return NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
ReturnsA new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free().
| yyjson_api char * yyjson_mut_val_write_opts | ( | const [yyjson_mut_val](#structyyjson mut val) * | val, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | size_t * | len, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a value to JSON string with options.
This function is thread-safe when:
val is not modified by other threads.alc is thread-safe or NULL.Parameters
| val | The mutable JSON root value. If this parameter is NULL, the function will fail and return NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ReturnsA new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free().
| yyjson_api bool yyjson_mut_val_write_file | ( | const char * | path, | | | | const [yyjson_mut_val](#structyyjson mut val) * | val, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a value to JSON file with options.
This function is thread-safe when:
val is not modified by other threads.alc is thread-safe or NULL.Parameters
| path | The JSON file's path. This should be a null-terminated string using the system's native encoding. If this path is NULL or invalid, the function will fail and return false. If this file is not empty, the content will be discarded. |
| val | The mutable JSON root value. If this parameter is NULL, the function will fail and return NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Returnstrue if successful, false if an error occurs.WarningOn 32-bit operating system, files larger than 2GB may fail to write.
| yyjson_api bool yyjson_mut_val_write_fp | ( | FILE * | fp, | | | | const [yyjson_mut_val](#structyyjson mut val) * | val, | | | | yyjson_write_flag | flg, | | | | const yyjson_alc * | alc, | | | | [yyjson_write_err](#structyyjson write err) * | err ) |
Write a value to JSON file with options.
Parameters
| fp | The file pointer. The data will be written to the current position of the file. If this path is NULL or invalid, the function will fail and return false. |
| val | The mutable JSON root value. If this parameter is NULL, the function will fail and return NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Returnstrue if successful, false if an error occurs.WarningOn 32-bit operating system, files larger than 2GB may fail to write.
| yyjson_api_inline char * yyjson_mut_val_write | ( | const [yyjson_mut_val](#structyyjson mut val) * | val, | | | | yyjson_write_flag | flg, | | | | size_t * | len ) |
Write a value to JSON string.
This function is thread-safe when: The val is not modified by other threads.
Parameters
| val | The JSON root value. If this parameter is NULL, the function will fail and return NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
ReturnsA new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free().
| yyjson_api char * yyjson_write_number | ( | const yyjson_val * | val, | | | | char * | buf ) |
Write a JSON number.
Parameters
| val | A JSON number value to be converted to a string. If this parameter is invalid, the function will fail and return NULL. | | buf | A buffer to store the resulting null-terminated string. If this parameter is NULL, the function will fail and return NULL. For integer values, the buffer must be at least 21 bytes. For floating-point values, the buffer must be at least 40 bytes. |
ReturnsOn success, returns a pointer to the character after the last written character. On failure, returns NULL. Note
YYJSON_DISABLE_FAST_FP_CONV is not defined).val or buf is NULL; 2) val is not a number type; 3) val is inf or nan, and non-standard JSON is explicitly disabled via the YYJSON_DISABLE_NON_STANDARD flag.| yyjson_api_inline char * yyjson_mut_write_number | ( | const [yyjson_mut_val](#structyyjson mut val) * | val, | | | | char * | buf ) |
Same as yyjson_write_number().
| yyjson_api_inline yyjson_val * yyjson_doc_get_root | ( | yyjson_doc * | doc | ) | |
Returns the root value of this JSON document. Returns NULL if doc is NULL.
| yyjson_api_inline size_t yyjson_doc_get_read_size | ( | yyjson_doc * | doc | ) | |
Returns read size of input JSON data. Returns 0 if doc is NULL. For example: the read size of [1,2,3] is 7 bytes.
| yyjson_api_inline size_t yyjson_doc_get_val_count | ( | yyjson_doc * | doc | ) | |
Returns total value count in this JSON document. Returns 0 if doc is NULL. For example: the value count of [1,2,3] is 4.
| yyjson_api_inline void yyjson_doc_free | ( | yyjson_doc * | doc | ) | |
Release the JSON document and free the memory. After calling this function, the doc and all values from the doc are no longer available. This function will do nothing if the doc is NULL.
| yyjson_api_inline bool yyjson_is_raw | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is raw. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_null | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is null. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_true | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is true. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_false | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is false. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_bool | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is bool (true/false). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_uint | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is unsigned integer (uint64_t). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_sint | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is signed integer (int64_t). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_int | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is integer (uint64_t/int64_t). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_real | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is real number (double). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_num | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is number (uint64_t/int64_t/double). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_str | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is string. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_arr | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is array. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_obj | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is object. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_is_ctn | ( | yyjson_val * | val | ) | |
Returns whether the JSON value is container (array/object). Returns false if val is NULL.
| yyjson_api_inline yyjson_type yyjson_get_type | ( | yyjson_val * | val | ) | |
Returns the JSON value's type. Returns YYJSON_TYPE_NONE if val is NULL.
| yyjson_api_inline yyjson_subtype yyjson_get_subtype | ( | yyjson_val * | val | ) | |
Returns the JSON value's subtype. Returns YYJSON_SUBTYPE_NONE if val is NULL.
| yyjson_api_inline uint8_t yyjson_get_tag | ( | yyjson_val * | val | ) | |
Returns the JSON value's tag. Returns 0 if val is NULL.
| yyjson_api_inline const char * yyjson_get_type_desc | ( | yyjson_val * | val | ) | |
Returns the JSON value's type description. The return value should be one of these strings: "raw", "null", "string", "array", "object", "true", "false", "uint", "sint", "real", "unknown".
| yyjson_api_inline const char * yyjson_get_raw | ( | yyjson_val * | val | ) | |
Returns the content if the value is raw. Returns NULL if val is NULL or type is not raw.
| yyjson_api_inline bool yyjson_get_bool | ( | yyjson_val * | val | ) | |
Returns the content if the value is bool. Returns false if val is NULL or type is not bool.
| yyjson_api_inline uint64_t yyjson_get_uint | ( | yyjson_val * | val | ) | |
Returns the content and cast to uint64_t. Returns 0 if val is NULL or type is not integer(sint/uint).
| yyjson_api_inline int64_t yyjson_get_sint | ( | yyjson_val * | val | ) | |
Returns the content and cast to int64_t. Returns 0 if val is NULL or type is not integer(sint/uint).
| yyjson_api_inline int yyjson_get_int | ( | yyjson_val * | val | ) | |
Returns the content and cast to int. Returns 0 if val is NULL or type is not integer(sint/uint).
| yyjson_api_inline double yyjson_get_real | ( | yyjson_val * | val | ) | |
Returns the content if the value is real number, or 0.0 on error. Returns 0.0 if val is NULL or type is not real(double).
| yyjson_api_inline double yyjson_get_num | ( | yyjson_val * | val | ) | |
Returns the content and typecast to double if the value is number. Returns 0.0 if val is NULL or type is not number(uint/sint/real).
| yyjson_api_inline const char * yyjson_get_str | ( | yyjson_val * | val | ) | |
Returns the content if the value is string. Returns NULL if val is NULL or type is not string.
| yyjson_api_inline size_t yyjson_get_len | ( | yyjson_val * | val | ) | |
Returns the content length (string length, array size, object size. Returns 0 if val is NULL or type is not string/array/object.
| yyjson_api_inline bool yyjson_equals_str | ( | yyjson_val * | val, | | | | const char * | str ) |
Returns whether the JSON value is equals to a string. Returns false if input is NULL or type is not string.
| yyjson_api_inline bool yyjson_equals_strn | ( | yyjson_val * | val, | | | | const char * | str, | | | | size_t | len ) |
Returns whether the JSON value is equals to a string. The str should be a UTF-8 string, null-terminator is not required. Returns false if input is NULL or type is not string.
| yyjson_api_inline bool yyjson_equals | ( | yyjson_val * | lhs, | | | | yyjson_val * | rhs ) |
Returns whether two JSON values are equal (deep compare). Returns false if input is NULL.
Notethe result may be inaccurate if object has duplicate keys. WarningThis function is recursive and may cause a stack overflow if the object level is too deep.
| yyjson_api_inline bool yyjson_set_raw | ( | yyjson_val * | val, | | | | const char * | raw, | | | | size_t | len ) |
Set the value to raw. Returns false if input is NULL or val is object or array.
WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_null | ( | yyjson_val * | val | ) | |
Set the value to null. Returns false if input is NULL or val is object or array.
WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_bool | ( | yyjson_val * | val, | | | | bool | num ) |
Set the value to bool. Returns false if input is NULL or val is object or array.
WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_uint | ( | yyjson_val * | val, | | | | uint64_t | num ) |
Set the value to uint. Returns false if input is NULL or val is object or array.
WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_sint | ( | yyjson_val * | val, | | | | int64_t | num ) |
Set the value to sint. Returns false if input is NULL or val is object or array.
WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_int | ( | yyjson_val * | val, | | | | int | num ) |
Set the value to int. Returns false if input is NULL or val is object or array.
WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_float | ( | yyjson_val * | val, | | | | float | num ) |
Set the value to float. Returns false if input is NULL or val is object or array.
WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_double | ( | yyjson_val * | val, | | | | double | num ) |
Set the value to double. Returns false if input is NULL or val is object or array.
WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_real | ( | yyjson_val * | val, | | | | double | num ) |
Set the value to real. Returns false if input is NULL or val is object or array.
WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_fp_to_fixed | ( | yyjson_val * | val, | | | | int | prec ) |
Set the floating-point number's output format to fixed-point notation. Returns false if input is NULL or val is not real type.
See alsoYYJSON_WRITE_FP_TO_FIXED flag. WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_fp_to_float | ( | yyjson_val * | val, | | | | bool | flt ) |
Set the floating-point number's output format to single-precision. Returns false if input is NULL or val is not real type.
See alsoYYJSON_WRITE_FP_TO_FLOAT flag. WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_str | ( | yyjson_val * | val, | | | | const char * | str ) |
Set the value to string (null-terminated). Returns false if input is NULL or val is object or array.
WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_strn | ( | yyjson_val * | val, | | | | const char * | str, | | | | size_t | len ) |
Set the value to string (with length). Returns false if input is NULL or val is object or array.
WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_set_str_noesc | ( | yyjson_val * | val, | | | | bool | noesc ) |
Marks this string as not needing to be escaped during JSON writing. This can be used to avoid the overhead of escaping if the string contains only characters that do not require escaping. Returns false if input is NULL or val is not string.
See alsoYYJSON_SUBTYPE_NOESC subtype. WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline size_t yyjson_arr_size | ( | yyjson_val * | arr | ) | |
Returns the number of elements in this array. Returns 0 if arr is NULL or type is not array.
| yyjson_api_inline yyjson_val * yyjson_arr_get | ( | yyjson_val * | arr, | | | | size_t | idx ) |
Returns the element at the specified position in this array. Returns NULL if array is NULL/empty or the index is out of bounds.
WarningThis function takes a linear search time if array is not flat. For example: [1,{},3] is flat, [1,[2],3] is not flat.
| yyjson_api_inline yyjson_val * yyjson_arr_get_first | ( | yyjson_val * | arr | ) | |
Returns the first element of this array. Returns NULL if arr is NULL/empty or type is not array.
| yyjson_api_inline yyjson_val * yyjson_arr_get_last | ( | yyjson_val * | arr | ) | |
Returns the last element of this array. Returns NULL if arr is NULL/empty or type is not array.
WarningThis function takes a linear search time if array is not flat. For example: [1,{},3] is flat, [1,[2],3] is not flat.
| yyjson_api_inline bool yyjson_arr_iter_init | ( | yyjson_val * | arr, | | | | [yyjson_arr_iter](#structyyjson arr iter) * | iter ) |
Initialize an iterator for this array.
Parameters
| arr | The array to be iterated over. If this parameter is NULL or not an array, iter will be set to empty. |
| iter | The iterator to be initialized. If this parameter is NULL, the function will fail and return false. |
Returnstrue if the iter has been successfully initialized.NoteThe iterator does not need to be destroyed.
| yyjson_api_inline [yyjson_arr_iter](#structyyjson arr iter) yyjson_arr_iter_with | ( | yyjson_val * | arr | ) | |
Create an iterator with an array , same as yyjson_arr_iter_init().
Parameters
| arr | The array to be iterated over. If this parameter is NULL or not an array, an empty iterator will returned. |
ReturnsA new iterator for the array.NoteThe iterator does not need to be destroyed.
| yyjson_api_inline bool yyjson_arr_iter_has_next | ( | [yyjson_arr_iter](#structyyjson arr iter) * | iter | ) | |
Returns whether the iteration has more elements. If iter is NULL, this function will return false.
| yyjson_api_inline yyjson_val * yyjson_arr_iter_next | ( | yyjson_arr_iter * | iter | ) | |
Returns the next element in the iteration, or NULL on end. If iter is NULL, this function will return NULL.
| yyjson_api_inline size_t yyjson_obj_size | ( | yyjson_val * | obj | ) | |
Returns the number of key-value pairs in this object. Returns 0 if obj is NULL or type is not object.
| yyjson_api_inline yyjson_val * yyjson_obj_get | ( | yyjson_val * | obj, | | | | const char * | key ) |
Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if obj/key is NULL, or type is not object.
The key should be a null-terminated UTF-8 string.
WarningThis function takes a linear search time.
| yyjson_api_inline yyjson_val * yyjson_obj_getn | ( | yyjson_val * | obj, | | | | const char * | key, | | | | size_t | key_len ) |
Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if obj/key is NULL, or type is not object.
The key should be a UTF-8 string, null-terminator is not required. The key_len should be the length of the key, in bytes.
WarningThis function takes a linear search time.
| yyjson_api_inline bool yyjson_obj_iter_init | ( | yyjson_val * | obj, | | | | [yyjson_obj_iter](#structyyjson obj iter) * | iter ) |
Initialize an iterator for this object.
Parameters
| obj | The object to be iterated over. If this parameter is NULL or not an object, iter will be set to empty. |
| iter | The iterator to be initialized. If this parameter is NULL, the function will fail and return false. |
Returnstrue if the iter has been successfully initialized.NoteThe iterator does not need to be destroyed.
| yyjson_api_inline [yyjson_obj_iter](#structyyjson obj iter) yyjson_obj_iter_with | ( | yyjson_val * | obj | ) | |
Create an iterator with an object, same as yyjson_obj_iter_init().
Parameters
| obj | The object to be iterated over. If this parameter is NULL or not an object, an empty iterator will returned. |
ReturnsA new iterator for the object.NoteThe iterator does not need to be destroyed.
| yyjson_api_inline bool yyjson_obj_iter_has_next | ( | [yyjson_obj_iter](#structyyjson obj iter) * | iter | ) | |
Returns whether the iteration has more elements. If iter is NULL, this function will return false.
| yyjson_api_inline yyjson_val * yyjson_obj_iter_next | ( | yyjson_obj_iter * | iter | ) | |
Returns the next key in the iteration, or NULL on end. If iter is NULL, this function will return NULL.
| yyjson_api_inline yyjson_val * yyjson_obj_iter_get_val | ( | yyjson_val * | key | ) | |
Returns the value for key inside the iteration. If iter is NULL, this function will return NULL.
| yyjson_api_inline yyjson_val * yyjson_obj_iter_get | ( | yyjson_obj_iter * | iter, | | | | const char * | key ) |
Iterates to a specified key and returns the value.
This function does the same thing as yyjson_obj_get(), but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned.
Parameters
| iter | The object iterator, should not be NULL. | | key | The key, should be a UTF-8 string with null-terminator. |
ReturnsThe value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid.WarningThis function takes a linear search time if the key is not nearby.
| yyjson_api_inline yyjson_val * yyjson_obj_iter_getn | ( | yyjson_obj_iter * | iter, | | | | const char * | key, | | | | size_t | key_len ) |
Iterates to a specified key and returns the value.
This function does the same thing as yyjson_obj_getn(), but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned.
Parameters
| iter | The object iterator, should not be NULL. |
| key | The key, should be a UTF-8 string, null-terminator is not required. |
| key_len | The the length of key, in bytes. |
ReturnsThe value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid.WarningThis function takes a linear search time if the key is not nearby.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_doc_get_root | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc | ) | |
Returns the root value of this JSON document. Returns NULL if doc is NULL.
| yyjson_api_inline void yyjson_mut_doc_set_root | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | root ) |
Sets the root value of this JSON document. Pass NULL to clear root value of the document.
| yyjson_api bool yyjson_mut_doc_set_str_pool_size | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | size_t | len ) |
Set the string pool size for a mutable document. This function does not allocate memory immediately, but uses the size when the next memory allocation is needed.
If the caller knows the approximate bytes of strings that the document needs to store (e.g. copy string with yyjson_mut_strcpy function), setting a larger size can avoid multiple memory allocations and improve performance.
Parameters
| doc | The mutable document. | | len | The desired string pool size in bytes (total string length). |
Returnstrue if successful, false if size is 0 or overflow.
| yyjson_api bool yyjson_mut_doc_set_val_pool_size | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | size_t | count ) |
Set the value pool size for a mutable document. This function does not allocate memory immediately, but uses the size when the next memory allocation is needed.
If the caller knows the approximate number of values that the document needs to store (e.g. create new value with yyjson_mut_xxx functions), setting a larger size can avoid multiple memory allocations and improve performance.
Parameters
| doc | The mutable document. |
| count | The desired value pool size (number of yyjson_mut_val). |
Returnstrue if successful, false if size is 0 or overflow.
| yyjson_api void yyjson_mut_doc_free | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc | ) | |
Release the JSON document and free the memory. After calling this function, the doc and all values from the doc are no longer available. This function will do nothing if the doc is NULL.
| yyjson_api [yyjson_mut_doc](#structyyjson mut doc) * yyjson_mut_doc_new | ( | const yyjson_alc * | alc | ) | |
Creates and returns a new mutable JSON document, returns NULL on error. If allocator is NULL, the default allocator will be used.
| yyjson_api [yyjson_mut_doc](#structyyjson mut doc) * yyjson_doc_mut_copy | ( | yyjson_doc * | doc, | | | | const yyjson_alc * | alc ) |
Copies and returns a new mutable document from input, returns NULL on error. This makes a deep-copy on the immutable document. If allocator is NULL, the default allocator will be used.
Noteimut_doc -> mut_doc.
| yyjson_api [yyjson_mut_doc](#structyyjson mut doc) * yyjson_mut_doc_mut_copy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const yyjson_alc * | alc ) |
Copies and returns a new mutable document from input, returns NULL on error. This makes a deep-copy on the mutable document. If allocator is NULL, the default allocator will be used.
Notemut_doc -> mut_doc.
| yyjson_api [yyjson_mut_val](#structyyjson mut val) * yyjson_val_mut_copy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | yyjson_val * | val ) |
Copies and returns a new mutable value from input, returns NULL on error. This makes a deep-copy on the immutable value. The memory was managed by mutable document.
Noteimut_val -> mut_val.
| yyjson_api [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_val_mut_copy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | val ) |
Copies and returns a new mutable value from input, returns NULL on error. This makes a deep-copy on the mutable value. The memory was managed by mutable document.
Notemut_val -> mut_val. WarningThis function is recursive and may cause a stack overflow if the object level is too deep.
| yyjson_api yyjson_doc * yyjson_mut_doc_imut_copy | ( | yyjson_mut_doc * | doc, | | | | const yyjson_alc * | alc ) |
Copies and returns a new immutable document from input, returns NULL on error. This makes a deep-copy on the mutable document. The returned document should be freed with yyjson_doc_free().
Notemut_doc -> imut_doc. WarningThis function is recursive and may cause a stack overflow if the object level is too deep.
| yyjson_api yyjson_doc * yyjson_mut_val_imut_copy | ( | yyjson_mut_val * | val, | | | | const yyjson_alc * | alc ) |
Copies and returns a new immutable document from input, returns NULL on error. This makes a deep-copy on the mutable value. The returned document should be freed with yyjson_doc_free().
Notemut_val -> imut_doc. WarningThis function is recursive and may cause a stack overflow if the object level is too deep.
| yyjson_api_inline bool yyjson_mut_is_raw | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is raw. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_null | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is null. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_true | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is true. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_false | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is false. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_bool | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is bool (true/false). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_uint | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is unsigned integer (uint64_t). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_sint | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is signed integer (int64_t). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_int | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is integer (uint64_t/int64_t). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_real | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is real number (double). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_num | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is number (uint/sint/real). Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_str | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is string. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_arr | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is array. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_obj | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is object. Returns false if val is NULL.
| yyjson_api_inline bool yyjson_mut_is_ctn | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns whether the JSON value is container (array/object). Returns false if val is NULL.
| yyjson_api_inline yyjson_type yyjson_mut_get_type | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the JSON value's type. Returns YYJSON_TYPE_NONE if val is NULL.
| yyjson_api_inline yyjson_subtype yyjson_mut_get_subtype | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the JSON value's subtype. Returns YYJSON_SUBTYPE_NONE if val is NULL.
| yyjson_api_inline uint8_t yyjson_mut_get_tag | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the JSON value's tag. Returns 0 if val is NULL.
| yyjson_api_inline const char * yyjson_mut_get_type_desc | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the JSON value's type description. The return value should be one of these strings: "raw", "null", "string", "array", "object", "true", "false", "uint", "sint", "real", "unknown".
| yyjson_api_inline const char * yyjson_mut_get_raw | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the content if the value is raw. Returns NULL if val is NULL or type is not raw.
| yyjson_api_inline bool yyjson_mut_get_bool | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the content if the value is bool. Returns NULL if val is NULL or type is not bool.
| yyjson_api_inline uint64_t yyjson_mut_get_uint | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the content and cast to uint64_t. Returns 0 if val is NULL or type is not integer(sint/uint).
| yyjson_api_inline int64_t yyjson_mut_get_sint | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the content and cast to int64_t. Returns 0 if val is NULL or type is not integer(sint/uint).
| yyjson_api_inline int yyjson_mut_get_int | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the content and cast to int. Returns 0 if val is NULL or type is not integer(sint/uint).
| yyjson_api_inline double yyjson_mut_get_real | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the content if the value is real number. Returns 0.0 if val is NULL or type is not real(double).
| yyjson_api_inline double yyjson_mut_get_num | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the content and typecast to double if the value is number. Returns 0.0 if val is NULL or type is not number(uint/sint/real).
| yyjson_api_inline const char * yyjson_mut_get_str | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the content if the value is string. Returns NULL if val is NULL or type is not string.
| yyjson_api_inline size_t yyjson_mut_get_len | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Returns the content length (string length, array size, object size. Returns 0 if val is NULL or type is not string/array/object.
| yyjson_api_inline bool yyjson_mut_equals_str | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | str ) |
Returns whether the JSON value is equals to a string. The str should be a null-terminated UTF-8 string. Returns false if input is NULL or type is not string.
| yyjson_api_inline bool yyjson_mut_equals_strn | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | str, | | | | size_t | len ) |
Returns whether the JSON value is equals to a string. The str should be a UTF-8 string, null-terminator is not required. Returns false if input is NULL or type is not string.
| yyjson_api_inline bool yyjson_mut_equals | ( | [yyjson_mut_val](#structyyjson mut val) * | lhs, | | | | [yyjson_mut_val](#structyyjson mut val) * | rhs ) |
Returns whether two JSON values are equal (deep compare). Returns false if input is NULL.
Notethe result may be inaccurate if object has duplicate keys. WarningThis function is recursive and may cause a stack overflow if the object level is too deep.
| yyjson_api_inline bool yyjson_mut_set_raw | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | raw, | | | | size_t | len ) |
Set the value to raw. Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_null | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Set the value to null. Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_bool | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | bool | num ) |
Set the value to bool. Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_uint | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | uint64_t | num ) |
Set the value to uint. Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_sint | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | int64_t | num ) |
Set the value to sint. Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_int | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | int | num ) |
Set the value to int. Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_float | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | float | num ) |
Set the value to float. Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_double | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | double | num ) |
Set the value to double. Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_real | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | double | num ) |
Set the value to real. Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_fp_to_fixed | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | int | prec ) |
Set the floating-point number's output format to fixed-point notation. Returns false if input is NULL or val is not real type.
See alsoYYJSON_WRITE_FP_TO_FIXED flag. WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_mut_set_fp_to_float | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | bool | flt ) |
Set the floating-point number's output format to single-precision. Returns false if input is NULL or val is not real type.
See alsoYYJSON_WRITE_FP_TO_FLOAT flag. WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_mut_set_str | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | str ) |
Set the value to string (null-terminated). Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_strn | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | str, | | | | size_t | len ) |
Set the value to string (with length). Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_str_noesc | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | bool | noesc ) |
Marks this string as not needing to be escaped during JSON writing. This can be used to avoid the overhead of escaping if the string contains only characters that do not require escaping. Returns false if input is NULL or val is not string.
See alsoYYJSON_SUBTYPE_NOESC subtype. WarningThis will modify the immutable value, use with caution.
| yyjson_api_inline bool yyjson_mut_set_arr | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Set the value to array. Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline bool yyjson_mut_set_obj | ( | [yyjson_mut_val](#structyyjson mut val) * | val | ) | |
Set the value to array. Returns false if input is NULL.
WarningThis function should not be used on an existing object or array.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_raw | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | str ) |
Creates and returns a raw value, returns NULL on error. The str should be a null-terminated UTF-8 string.
WarningThe input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_rawn | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | str, | | | | size_t | len ) |
Creates and returns a raw value, returns NULL on error. The str should be a UTF-8 string, null-terminator is not required.
WarningThe input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_rawcpy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | str ) |
Creates and returns a raw value, returns NULL on error. The str should be a null-terminated UTF-8 string. The input string is copied and held by the document.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_rawncpy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | str, | | | | size_t | len ) |
Creates and returns a raw value, returns NULL on error. The str should be a UTF-8 string, null-terminator is not required. The input string is copied and held by the document.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_null | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc | ) | |
Creates and returns a null value, returns NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_true | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc | ) | |
Creates and returns a true value, returns NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_false | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc | ) | |
Creates and returns a false value, returns NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_bool | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | bool | val ) |
Creates and returns a bool value, returns NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_uint | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | uint64_t | num ) |
Creates and returns an unsigned integer value, returns NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_sint | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | int64_t | num ) |
Creates and returns a signed integer value, returns NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_int | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | int64_t | num ) |
Creates and returns a signed integer value, returns NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_float | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | float | num ) |
Creates and returns a float number value, returns NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_double | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | double | num ) |
Creates and returns a double number value, returns NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_real | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | double | num ) |
Creates and returns a real number value, returns NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_str | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | str ) |
Creates and returns a string value, returns NULL on error. The str should be a null-terminated UTF-8 string.
WarningThe input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_strn | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | str, | | | | size_t | len ) |
Creates and returns a string value, returns NULL on error. The str should be a UTF-8 string, null-terminator is not required.
WarningThe input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_strcpy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | str ) |
Creates and returns a string value, returns NULL on error. The str should be a null-terminated UTF-8 string. The input string is copied and held by the document.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_strncpy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | str, | | | | size_t | len ) |
Creates and returns a string value, returns NULL on error. The str should be a UTF-8 string, null-terminator is not required. The input string is copied and held by the document.
| yyjson_api_inline size_t yyjson_mut_arr_size | ( | [yyjson_mut_val](#structyyjson mut val) * | arr | ) | |
Returns the number of elements in this array. Returns 0 if arr is NULL or type is not array.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_get | ( | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | size_t | idx ) |
Returns the element at the specified position in this array. Returns NULL if array is NULL/empty or the index is out of bounds.
WarningThis function takes a linear search time.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_get_first | ( | [yyjson_mut_val](#structyyjson mut val) * | arr | ) | |
Returns the first element of this array. Returns NULL if arr is NULL/empty or type is not array.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_get_last | ( | [yyjson_mut_val](#structyyjson mut val) * | arr | ) | |
Returns the last element of this array. Returns NULL if arr is NULL/empty or type is not array.
| yyjson_api_inline bool yyjson_mut_arr_iter_init | ( | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | [yyjson_mut_arr_iter](#structyyjson mut arr__iter) * | iter ) |
Initialize an iterator for this array.
Parameters
| arr | The array to be iterated over. If this parameter is NULL or not an array, iter will be set to empty. |
| iter | The iterator to be initialized. If this parameter is NULL, the function will fail and return false. |
Returnstrue if the iter has been successfully initialized.NoteThe iterator does not need to be destroyed.
| yyjson_api_inline [yyjson_mut_arr_iter](#structyyjson mut arr__iter) yyjson_mut_arr_iter_with | ( | yyjson_mut_val * | arr | ) | |
Create an iterator with an array , same as yyjson_mut_arr_iter_init().
Parameters
| arr | The array to be iterated over. If this parameter is NULL or not an array, an empty iterator will returned. |
ReturnsA new iterator for the array.NoteThe iterator does not need to be destroyed.
| yyjson_api_inline bool yyjson_mut_arr_iter_has_next | ( | [yyjson_mut_arr_iter](#structyyjson mut arr__iter) * | iter | ) | |
Returns whether the iteration has more elements. If iter is NULL, this function will return false.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_iter_next | ( | [yyjson_mut_arr_iter](#structyyjson mut arr__iter) * | iter | ) | |
Returns the next element in the iteration, or NULL on end. If iter is NULL, this function will return NULL.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_iter_remove | ( | [yyjson_mut_arr_iter](#structyyjson mut arr__iter) * | iter | ) | |
Removes and returns current element in the iteration. If iter is NULL, this function will return NULL.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc | ) | |
Creates and returns an empty mutable array.
Parameters
| doc | A mutable document, used for memory allocation only. |
ReturnsThe new array. NULL if input is NULL or memory allocation failed.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_bool | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const bool * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given boolean values.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of boolean values. | | count | The value count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const bool vals[3] = { true, false, true };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_bool(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_bool(yyjson_mut_doc *doc, const bool *vals, size_t count)
Definition yyjson.h:6226
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_sint | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const int64_t * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given sint numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of sint numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const int64_t vals[3] = { -1, 0, 1 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_sint64(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint64(yyjson_mut_doc *doc, const int64_t *vals, size_t count)
Definition yyjson.h:6271
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_uint | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const uint64_t * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given uint numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of uint numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const uint64_t vals[3] = { 0, 1, 0 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_uint(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint(yyjson_mut_doc *doc, const uint64_t *vals, size_t count)
Definition yyjson.h:6238
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_real | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const double * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given real numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of real numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const double vals[3] = { 0.1, 0.2, 0.3 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_real(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_real(yyjson_mut_doc *doc, const double *vals, size_t count)
Definition yyjson.h:6243
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_sint8 | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const int8_t * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given int8 numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of int8 numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const int8_t vals[3] = { -1, 0, 1 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_sint8(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint8(yyjson_mut_doc *doc, const int8_t *vals, size_t count)
Definition yyjson.h:6250
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_sint16 | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const int16_t * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given int16 numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of int16 numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const int16_t vals[3] = { -1, 0, 1 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_sint16(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint16(yyjson_mut_doc *doc, const int16_t *vals, size_t count)
Definition yyjson.h:6257
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_sint32 | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const int32_t * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given int32 numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of int32 numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const int32_t vals[3] = { -1, 0, 1 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_sint32(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint32(yyjson_mut_doc *doc, const int32_t *vals, size_t count)
Definition yyjson.h:6264
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_sint64 | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const int64_t * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given int64 numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of int64 numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const int64_t vals[3] = { -1, 0, 1 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_sint64(doc, vals, 3);
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_uint8 | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const uint8_t * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given uint8 numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of uint8 numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const uint8_t vals[3] = { 0, 1, 0 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_uint8(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint8(yyjson_mut_doc *doc, const uint8_t *vals, size_t count)
Definition yyjson.h:6278
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_uint16 | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const uint16_t * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given uint16 numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of uint16 numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const uint16_t vals[3] = { 0, 1, 0 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_uint16(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint16(yyjson_mut_doc *doc, const uint16_t *vals, size_t count)
Definition yyjson.h:6285
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_uint32 | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const uint32_t * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given uint32 numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of uint32 numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const uint32_t vals[3] = { 0, 1, 0 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_uint32(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint32(yyjson_mut_doc *doc, const uint32_t *vals, size_t count)
Definition yyjson.h:6292
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_uint64 | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const uint64_t * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given uint64 numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of uint64 numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const uint64_t vals[3] = { 0, 1, 0 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_uint64(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint64(yyjson_mut_doc *doc, const uint64_t *vals, size_t count)
Definition yyjson.h:6299
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_float | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const float * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given float numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of float numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const float vals[3] = { -1.0f, 0.0f, 1.0f };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_float(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_float(yyjson_mut_doc *doc, const float *vals, size_t count)
Definition yyjson.h:6306
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_double | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const double * | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given double numbers.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. | | vals | A C array of double numbers. | | count | The number count. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const double vals[3] = { -1.0, 0.0, 1.0 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_double(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_double(yyjson_mut_doc *doc, const double *vals, size_t count)
Definition yyjson.h:6313
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_str | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char ** | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given strings, these strings will not be copied.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of UTF-8 null-terminator strings. If this array contains NULL, the function will fail and return NULL. |
| count | The number of values in vals. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.WarningThe input strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. If these strings will be modified, you should use yyjson_mut_arr_with_strcpy() instead.
Example
const char *vals[3] = { "a", "b", "c" };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_str(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_str(yyjson_mut_doc *doc, const char **vals, size_t count)
Definition yyjson.h:6320
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_strn | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char ** | vals, | | | | const size_t * | lens, | | | | size_t | count ) |
Creates and returns a new mutable array with the given strings and string lengths, these strings will not be copied.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of UTF-8 strings, null-terminator is not required. If this array contains NULL, the function will fail and return NULL. |
| lens | A C array of string lengths, in bytes. |
| count | The number of strings in vals. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.WarningThe input strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. If these strings will be modified, you should use yyjson_mut_arr_with_strncpy() instead.
Example
const char *vals[3] = { "a", "bb", "c" };
const size_t lens[3] = { 1, 2, 1 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_strn(doc, vals, lens, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_strn(yyjson_mut_doc *doc, const char **vals, const size_t *lens, size_t count)
Definition yyjson.h:6328
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_strcpy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char ** | vals, | | | | size_t | count ) |
Creates and returns a new mutable array with the given strings, these strings will be copied.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of UTF-8 null-terminator strings. If this array contains NULL, the function will fail and return NULL. |
| count | The number of values in vals. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const char *vals[3] = { "a", "b", "c" };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_strcpy(doc, vals, 3);
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_strcpy(yyjson_mut_doc *doc, const char **vals, size_t count)
Definition yyjson.h:6337
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_with_strncpy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char ** | vals, | | | | const size_t * | lens, | | | | size_t | count ) |
Creates and returns a new mutable array with the given strings and string lengths, these strings will be copied.
Parameters
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of UTF-8 strings, null-terminator is not required. If this array contains NULL, the function will fail and return NULL. |
| lens | A C array of string lengths, in bytes. |
| count | The number of strings in vals. If this value is 0, an empty array will return. |
ReturnsThe new array. NULL if input is invalid or memory allocation failed.
Example
const char *vals[3] = { "a", "bb", "c" };
const size_t lens[3] = { 1, 2, 1 };
[yyjson_mut_val](#structyyjson mut val) *arr = yyjson_mut_arr_with_strn(doc, vals, lens, 3);
| yyjson_api_inline bool yyjson_mut_arr_insert | ( | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | size_t | idx ) |
Inserts a value into an array at a given index.
Parameters
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. | | val | The value to be inserted. Returns false if it is NULL. | | idx | The index to which to insert the new value. Returns false if the index is out of range. |
ReturnsWhether successful. WarningThis function takes a linear search time.
| yyjson_api_inline bool yyjson_mut_arr_append | ( | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | [yyjson_mut_val](#structyyjson mut val) * | val ) |
Inserts a value at the end of the array.
Parameters
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. | | val | The value to be inserted. Returns false if it is NULL. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_prepend | ( | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | [yyjson_mut_val](#structyyjson mut val) * | val ) |
Inserts a value at the head of the array.
Parameters
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. | | val | The value to be inserted. Returns false if it is NULL. |
ReturnsWhether successful.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_replace | ( | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | size_t | idx, | | | | [yyjson_mut_val](#structyyjson mut val) * | val ) |
Replaces a value at index and returns old value.
Parameters
| arr | The array to which the value is to be replaced. Returns false if it is NULL or not an array. | | idx | The index to which to replace the value. Returns false if the index is out of range. | | val | The new value to replace. Returns false if it is NULL. |
ReturnsOld value, or NULL on error. WarningThis function takes a linear search time.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_remove | ( | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | size_t | idx ) |
Removes and returns a value at index.
Parameters
| arr | The array from which the value is to be removed. Returns false if it is NULL or not an array. | | idx | The index from which to remove the value. Returns false if the index is out of range. |
ReturnsOld value, or NULL on error. WarningThis function takes a linear search time.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_remove_first | ( | [yyjson_mut_val](#structyyjson mut val) * | arr | ) | |
Removes and returns the first value in this array.
Parameters
| arr | The array from which the value is to be removed. Returns false if it is NULL or not an array. |
ReturnsThe first value, or NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_remove_last | ( | [yyjson_mut_val](#structyyjson mut val) * | arr | ) | |
Removes and returns the last value in this array.
Parameters
| arr | The array from which the value is to be removed. Returns false if it is NULL or not an array. |
ReturnsThe last value, or NULL on error.
| yyjson_api_inline bool yyjson_mut_arr_remove_range | ( | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | size_t | idx, | | | | size_t | len ) |
Removes all values within a specified range in the array.
Parameters
| arr | The array from which the value is to be removed. Returns false if it is NULL or not an array. | | idx | The start index of the range (0 is the first). | | len | The number of items in the range (can be 0). |
ReturnsWhether successful. WarningThis function takes a linear search time.
| yyjson_api_inline bool yyjson_mut_arr_clear | ( | [yyjson_mut_val](#structyyjson mut val) * | arr | ) | |
Removes all values in this array.
Parameters
| arr | The array from which all of the values are to be removed. Returns false if it is NULL or not an array. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_rotate | ( | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | size_t | idx ) |
Rotates values in this array for the given number of times. For example: [1,2,3,4,5] rotate 2 is [3,4,5,1,2].
Parameters
| arr | The array to be rotated. | | idx | Index (or times) to rotate. |
WarningThis function takes a linear search time.
| yyjson_api_inline bool yyjson_mut_arr_add_val | ( | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | [yyjson_mut_val](#structyyjson mut val) * | val ) |
Adds a value at the end of the array.
Parameters
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. | | val | The value to be inserted. Returns false if it is NULL. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_null | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr ) |
Adds a null value at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_true | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr ) |
Adds a true value at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_false | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr ) |
Adds a false value at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_bool | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | bool | val ) |
Adds a bool value at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| val | The bool value to be added. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_uint | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | uint64_t | num ) |
Adds an unsigned integer value at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| num | The number to be added. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_sint | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | int64_t | num ) |
Adds a signed integer value at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| num | The number to be added. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_int | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | int64_t | num ) |
Adds an integer value at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| num | The number to be added. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_float | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | float | num ) |
Adds a float value at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| num | The number to be added. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_double | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | double | num ) |
Adds a double value at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| num | The number to be added. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_real | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | double | num ) |
Adds a double value at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| num | The number to be added. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_str | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | const char * | str ) |
Adds a string value at the end of the array (no copy).
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| str | A null-terminated UTF-8 string. |
ReturnsWhether successful. WarningThe input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_arr_add_strn | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | const char * | str, | | | | size_t | len ) |
Adds a string value at the end of the array (no copy).
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| str | A UTF-8 string, null-terminator is not required. |
| len | The length of the string, in bytes. |
ReturnsWhether successful. WarningThe input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_arr_add_strcpy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | const char * | str ) |
Adds a string value at the end of the array (copied).
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| str | A null-terminated UTF-8 string. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_arr_add_strncpy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr, | | | | const char * | str, | | | | size_t | len ) |
Adds a string value at the end of the array (copied).
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| str | A UTF-8 string, null-terminator is not required. |
| len | The length of the string, in bytes. |
ReturnsWhether successful.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_add_arr | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr ) |
Creates and adds a new array at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
ReturnsThe new array, or NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_arr_add_obj | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | arr ) |
Creates and adds a new object at the end of the array.
Parameters
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
ReturnsThe new object, or NULL on error.
| yyjson_api_inline size_t yyjson_mut_obj_size | ( | [yyjson_mut_val](#structyyjson mut val) * | obj | ) | |
Returns the number of key-value pairs in this object. Returns 0 if obj is NULL or type is not object.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_get | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key ) |
Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if obj/key is NULL, or type is not object.
The key should be a null-terminated UTF-8 string.
WarningThis function takes a linear search time.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_getn | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | size_t | key_len ) |
Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if obj/key is NULL, or type is not object.
The key should be a UTF-8 string, null-terminator is not required. The key_len should be the length of the key, in bytes.
WarningThis function takes a linear search time.
| yyjson_api_inline bool yyjson_mut_obj_iter_init | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | [yyjson_mut_obj_iter](#structyyjson mut obj__iter) * | iter ) |
Initialize an iterator for this object.
Parameters
| obj | The object to be iterated over. If this parameter is NULL or not an array, iter will be set to empty. |
| iter | The iterator to be initialized. If this parameter is NULL, the function will fail and return false. |
Returnstrue if the iter has been successfully initialized.NoteThe iterator does not need to be destroyed.
| yyjson_api_inline [yyjson_mut_obj_iter](#structyyjson mut obj__iter) yyjson_mut_obj_iter_with | ( | yyjson_mut_val * | obj | ) | |
Create an iterator with an object, same as yyjson_obj_iter_init().
Parameters
| obj | The object to be iterated over. If this parameter is NULL or not an object, an empty iterator will returned. |
ReturnsA new iterator for the object.NoteThe iterator does not need to be destroyed.
| yyjson_api_inline bool yyjson_mut_obj_iter_has_next | ( | [yyjson_mut_obj_iter](#structyyjson mut obj__iter) * | iter | ) | |
Returns whether the iteration has more elements. If iter is NULL, this function will return false.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_iter_next | ( | [yyjson_mut_obj_iter](#structyyjson mut obj__iter) * | iter | ) | |
Returns the next key in the iteration, or NULL on end. If iter is NULL, this function will return NULL.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_iter_get_val | ( | [yyjson_mut_val](#structyyjson mut val) * | key | ) | |
Returns the value for key inside the iteration. If iter is NULL, this function will return NULL.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_iter_remove | ( | [yyjson_mut_obj_iter](#structyyjson mut obj__iter) * | iter | ) | |
Removes current key-value pair in the iteration, returns the removed value. If iter is NULL, this function will return NULL.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_iter_get | ( | [yyjson_mut_obj_iter](#structyyjson mut obj__iter) * | iter, | | | | const char * | key ) |
Iterates to a specified key and returns the value.
This function does the same thing as yyjson_mut_obj_get(), but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned.
Parameters
| iter | The object iterator, should not be NULL. | | key | The key, should be a UTF-8 string with null-terminator. |
ReturnsThe value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid.WarningThis function takes a linear search time if the key is not nearby.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_iter_getn | ( | [yyjson_mut_obj_iter](#structyyjson mut obj__iter) * | iter, | | | | const char * | key, | | | | size_t | key_len ) |
Iterates to a specified key and returns the value.
This function does the same thing as yyjson_mut_obj_getn() but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned.
Parameters
| iter | The object iterator, should not be NULL. |
| key | The key, should be a UTF-8 string, null-terminator is not required. |
| key_len | The the length of key, in bytes. |
ReturnsThe value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid.WarningThis function takes a linear search time if the key is not nearby.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc | ) | |
Creates and returns a mutable object, returns NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_with_str | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char ** | keys, | | | | const char ** | vals, | | | | size_t | count ) |
Creates and returns a mutable object with keys and values, returns NULL on error. The keys and values are not copied. The strings should be a null-terminated UTF-8 string.
WarningThe input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.
Example
const char *keys[2] = { "id", "name" };
const char *vals[2] = { "01", "Harry" };
[yyjson_mut_val](#structyyjson mut val) *obj = yyjson_mut_obj_with_str(doc, keys, vals, 2);
yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_with_str(yyjson_mut_doc *doc, const char **keys, const char **vals, size_t count)
Definition yyjson.h:6881
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_with_kv | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char ** | kv_pairs, | | | | size_t | pair_count ) |
Creates and returns a mutable object with key-value pairs and pair count, returns NULL on error. The keys and values are not copied. The strings should be a null-terminated UTF-8 string.
WarningThe input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.
Example
const char *kv_pairs[4] = { "id", "01", "name", "Harry" };
[yyjson_mut_val](#structyyjson mut val) *obj = yyjson_mut_obj_with_kv(doc, kv_pairs, 2);
yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_with_kv(yyjson_mut_doc *doc, const char **kv_pairs, size_t pair_count)
Definition yyjson.h:6912
| yyjson_api_inline bool yyjson_mut_obj_add | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | [yyjson_mut_val](#structyyjson mut val) * | key, | | | | [yyjson_mut_val](#structyyjson mut val) * | val ) |
Adds a key-value pair at the end of the object. This function allows duplicated key in one object.
Parameters
| obj | The object to which the new key-value pair is to be added. |
| key | The key, should be a string which is created by yyjson_mut_str(), yyjson_mut_strn(), yyjson_mut_strcpy() or yyjson_mut_strncpy(). |
| val | The value to add to the object. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_obj_put | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | [yyjson_mut_val](#structyyjson mut val) * | key, | | | | [yyjson_mut_val](#structyyjson mut val) * | val ) |
Sets a key-value pair at the end of the object. This function may remove all key-value pairs for the given key before add.
Parameters
| obj | The object to which the new key-value pair is to be added. |
| key | The key, should be a string which is created by yyjson_mut_str(), yyjson_mut_strn(), yyjson_mut_strcpy() or yyjson_mut_strncpy(). |
| val | The value to add to the object. If this value is null, the behavior is same as yyjson_mut_obj_remove(). |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_obj_insert | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | [yyjson_mut_val](#structyyjson mut val) * | key, | | | | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | size_t | idx ) |
Inserts a key-value pair to the object at the given position. This function allows duplicated key in one object.
Parameters
| obj | The object to which the new key-value pair is to be added. |
| key | The key, should be a string which is created by yyjson_mut_str(), yyjson_mut_strn(), yyjson_mut_strcpy() or yyjson_mut_strncpy(). |
| val | The value to add to the object. |
| idx | The index to which to insert the new pair. |
ReturnsWhether successful.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_remove | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | [yyjson_mut_val](#structyyjson mut val) * | key ) |
Removes all key-value pair from the object with given key.
Parameters
| obj | The object from which the key-value pair is to be removed. | | key | The key, should be a string value. |
ReturnsThe first matched value, or NULL if no matched value. WarningThis function takes a linear search time.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_remove_key | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key ) |
Removes all key-value pair from the object with given key.
Parameters
| obj | The object from which the key-value pair is to be removed. | | key | The key, should be a UTF-8 string with null-terminator. |
ReturnsThe first matched value, or NULL if no matched value. WarningThis function takes a linear search time.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_remove_keyn | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | size_t | key_len ) |
Removes all key-value pair from the object with given key.
Parameters
| obj | The object from which the key-value pair is to be removed. | | key | The key, should be a UTF-8 string, null-terminator is not required. | | key_len | The length of the key. |
ReturnsThe first matched value, or NULL if no matched value. WarningThis function takes a linear search time.
| yyjson_api_inline bool yyjson_mut_obj_clear | ( | [yyjson_mut_val](#structyyjson mut val) * | obj | ) | |
Removes all key-value pairs in this object.
Parameters
| obj | The object from which all of the values are to be removed. |
ReturnsWhether successful.
| yyjson_api_inline bool yyjson_mut_obj_replace | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | [yyjson_mut_val](#structyyjson mut val) * | key, | | | | [yyjson_mut_val](#structyyjson mut val) * | val ) |
Replaces value from the object with given key. If the key is not exist, or the value is NULL, it will fail.
Parameters
| obj | The object to which the value is to be replaced. | | key | The key, should be a string value. | | val | The value to replace into the object. |
ReturnsWhether successful. WarningThis function takes a linear search time.
| yyjson_api_inline bool yyjson_mut_obj_rotate | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | size_t | idx ) |
Rotates key-value pairs in the object for the given number of times. For example: {"a":1,"b":2,"c":3,"d":4} rotate 1 is {"b":2,"c":3,"d":4,"a":1}.
Parameters
| obj | The object to be rotated. | | idx | Index (or times) to rotate. |
ReturnsWhether successful. WarningThis function takes a linear search time.
| yyjson_api_inline bool yyjson_mut_obj_add_null | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key ) |
Adds a null value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_true | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key ) |
Adds a true value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_false | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key ) |
Adds a false value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_bool | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | bool | val ) |
Adds a bool value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_uint | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | uint64_t | val ) |
Adds an unsigned integer value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_sint | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | int64_t | val ) |
Adds a signed integer value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_int | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | int64_t | val ) |
Adds an int value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_float | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | float | val ) |
Adds a float value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_double | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | double | val ) |
Adds a double value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_real | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | double | val ) |
Adds a real value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_str | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | const char * | val ) |
Adds a string value at the end of the object. The key and val should be null-terminated UTF-8 strings. This function allows duplicated key in one object.
WarningThe key/value strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_strn | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | const char * | val, | | | | size_t | len ) |
Adds a string value at the end of the object. The key should be a null-terminated UTF-8 string. The val should be a UTF-8 string, null-terminator is not required. The len should be the length of the val, in bytes. This function allows duplicated key in one object.
WarningThe key/value strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_strcpy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | const char * | val ) |
Adds a string value at the end of the object. The key and val should be null-terminated UTF-8 strings. The value string is copied. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline bool yyjson_mut_obj_add_strncpy | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | const char * | val, | | | | size_t | len ) |
Adds a string value at the end of the object. The key should be a null-terminated UTF-8 string. The val should be a UTF-8 string, null-terminator is not required. The len should be the length of the val, in bytes. This function allows duplicated key in one object.
WarningThe key strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_add_arr | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key ) |
Creates and adds a new array to the target object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep these strings unmodified for the lifetime of this JSON document. ReturnsThe new array, or NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_add_obj | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key ) |
Creates and adds a new object to the target object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep these strings unmodified for the lifetime of this JSON document. ReturnsThe new object, or NULL on error.
| yyjson_api_inline bool yyjson_mut_obj_add_val | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | [yyjson_mut_val](#structyyjson mut val) * | val ) |
Adds a JSON value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
WarningThe key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_remove_str | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key ) |
Removes all key-value pairs for the given key. Returns the first value to which the specified key is mapped or NULL if this object contains no mapping for the key. The key should be a null-terminated UTF-8 string.
WarningThis function takes a linear search time.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_obj_remove_strn | ( | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | size_t | len ) |
Removes all key-value pairs for the given key. Returns the first value to which the specified key is mapped or NULL if this object contains no mapping for the key. The key should be a UTF-8 string, null-terminator is not required. The len should be the length of the key, in bytes.
WarningThis function takes a linear search time.
| yyjson_api_inline bool yyjson_mut_obj_rename_key | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | const char * | new_key ) |
Replaces all matching keys with the new key. Returns true if at least one key was renamed. The key and new_key should be a null-terminated UTF-8 string. The new_key is copied and held by doc.
WarningThis function takes a linear search time. If new_key already exists, it will cause duplicate keys.
| yyjson_api_inline bool yyjson_mut_obj_rename_keyn | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | obj, | | | | const char * | key, | | | | size_t | len, | | | | const char * | new_key, | | | | size_t | new_len ) |
Replaces all matching keys with the new key. Returns true if at least one key was renamed. The key and new_key should be a UTF-8 string, null-terminator is not required. The new_key is copied and held by doc.
WarningThis function takes a linear search time. If new_key already exists, it will cause duplicate keys.
| yyjson_api_inline yyjson_val * yyjson_doc_ptr_get | ( | yyjson_doc * | doc, | | | | const char * | ptr ) |
Get value by a JSON Pointer.
Parameters
| doc | The JSON document to be queried. | | ptr | The JSON pointer string (UTF-8 with null-terminator). |
ReturnsThe value referenced by the JSON pointer. NULL if doc or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline yyjson_val * yyjson_doc_ptr_getn | ( | yyjson_doc * | doc, | | | | const char * | ptr, | | | | size_t | len ) |
Get value by a JSON Pointer.
Parameters
| doc | The JSON document to be queried. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
ReturnsThe value referenced by the JSON pointer. NULL if doc or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline yyjson_val * yyjson_doc_ptr_getx | ( | yyjson_doc * | doc, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Get value by a JSON Pointer.
Parameters
| doc | The JSON document to be queried. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| err | A pointer to store the error information, or NULL if not needed. |
ReturnsThe value referenced by the JSON pointer. NULL if doc or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline yyjson_val * yyjson_ptr_get | ( | yyjson_val * | val, | | | | const char * | ptr ) |
Get value by a JSON Pointer.
Parameters
| val | The JSON value to be queried. | | ptr | The JSON pointer string (UTF-8 with null-terminator). |
ReturnsThe value referenced by the JSON pointer. NULL if val or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline yyjson_val * yyjson_ptr_getn | ( | yyjson_val * | val, | | | | const char * | ptr, | | | | size_t | len ) |
Get value by a JSON Pointer.
Parameters
| val | The JSON value to be queried. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
ReturnsThe value referenced by the JSON pointer. NULL if val or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline yyjson_val * yyjson_ptr_getx | ( | yyjson_val * | val, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Get value by a JSON Pointer.
Parameters
| val | The JSON value to be queried. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| err | A pointer to store the error information, or NULL if not needed. |
ReturnsThe value referenced by the JSON pointer. NULL if val or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_doc_ptr_get | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr ) |
Get value by a JSON Pointer.
Parameters
| doc | The JSON document to be queried. | | ptr | The JSON pointer string (UTF-8 with null-terminator). |
ReturnsThe value referenced by the JSON pointer. NULL if doc or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_doc_ptr_getn | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | size_t | len ) |
Get value by a JSON Pointer.
Parameters
| doc | The JSON document to be queried. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
ReturnsThe value referenced by the JSON pointer. NULL if doc or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_doc_ptr_getx | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Get value by a JSON Pointer.
Parameters
| doc | The JSON document to be queried. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
ReturnsThe value referenced by the JSON pointer. NULL if doc or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_ptr_get | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr ) |
Get value by a JSON Pointer.
Parameters
| val | The JSON value to be queried. | | ptr | The JSON pointer string (UTF-8 with null-terminator). |
ReturnsThe value referenced by the JSON pointer. NULL if val or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_ptr_getn | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | size_t | len ) |
Get value by a JSON Pointer.
Parameters
| val | The JSON value to be queried. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
ReturnsThe value referenced by the JSON pointer. NULL if val or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_ptr_getx | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Get value by a JSON Pointer.
Parameters
| val | The JSON value to be queried. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
ReturnsThe value referenced by the JSON pointer. NULL if val or ptr is NULL, or the JSON pointer cannot be resolved.
| yyjson_api_inline bool yyjson_mut_doc_ptr_add | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val ) |
Add (insert) value by a JSON pointer.
Parameters
| doc | The target JSON document. | | ptr | The JSON pointer string (UTF-8 with null-terminator). | | new_val | The value to be added. |
Returnstrue if JSON pointer is valid and new value is added, false otherwise. NoteThe parent nodes will be created if they do not exist.
| yyjson_api_inline bool yyjson_mut_doc_ptr_addn | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val ) |
Add (insert) value by a JSON pointer.
Parameters
| doc | The target JSON document. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be added. |
Returnstrue if JSON pointer is valid and new value is added, false otherwise. NoteThe parent nodes will be created if they do not exist.
| yyjson_api_inline bool yyjson_mut_doc_ptr_addx | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val, | | | | bool | create_parent, | | | | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Add (insert) value by a JSON pointer.
Parameters
| doc | The target JSON document. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be added. |
| create_parent | Whether to create parent nodes if not exist. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
Returnstrue if JSON pointer is valid and new value is added, false otherwise.
| yyjson_api_inline bool yyjson_mut_ptr_add | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val, | | | | [yyjson_mut_doc](#structyyjson mut doc) * | doc ) |
Add (insert) value by a JSON pointer.
Parameters
| val | The target JSON value. | | ptr | The JSON pointer string (UTF-8 with null-terminator). | | doc | Only used to create new values when needed. | | new_val | The value to be added. |
Returnstrue if JSON pointer is valid and new value is added, false otherwise. NoteThe parent nodes will be created if they do not exist.
| yyjson_api_inline bool yyjson_mut_ptr_addn | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val, | | | | [yyjson_mut_doc](#structyyjson mut doc) * | doc ) |
Add (insert) value by a JSON pointer.
Parameters
| val | The target JSON value. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| doc | Only used to create new values when needed. |
| new_val | The value to be added. |
Returnstrue if JSON pointer is valid and new value is added, false otherwise. NoteThe parent nodes will be created if they do not exist.
| yyjson_api_inline bool yyjson_mut_ptr_addx | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val, | | | | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | bool | create_parent, | | | | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Add (insert) value by a JSON pointer.
Parameters
| val | The target JSON value. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| doc | Only used to create new values when needed. |
| new_val | The value to be added. |
| create_parent | Whether to create parent nodes if not exist. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
Returnstrue if JSON pointer is valid and new value is added, false otherwise.
| yyjson_api_inline bool yyjson_mut_doc_ptr_set | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val ) |
Set value by a JSON pointer.
Parameters
| doc | The target JSON document. | | ptr | The JSON pointer string (UTF-8 with null-terminator). | | new_val | The value to be set, pass NULL to remove. |
Returnstrue if JSON pointer is valid and new value is set, false otherwise. NoteThe parent nodes will be created if they do not exist. If the target value already exists, it will be replaced by the new value.
| yyjson_api_inline bool yyjson_mut_doc_ptr_setn | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val ) |
Set value by a JSON pointer.
Parameters
| doc | The target JSON document. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be set, pass NULL to remove. |
Returnstrue if JSON pointer is valid and new value is set, false otherwise. NoteThe parent nodes will be created if they do not exist. If the target value already exists, it will be replaced by the new value.
| yyjson_api_inline bool yyjson_mut_doc_ptr_setx | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val, | | | | bool | create_parent, | | | | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Set value by a JSON pointer.
Parameters
| doc | The target JSON document. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be set, pass NULL to remove. |
| create_parent | Whether to create parent nodes if not exist. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
Returnstrue if JSON pointer is valid and new value is set, false otherwise. NoteIf the target value already exists, it will be replaced by the new value.
| yyjson_api_inline bool yyjson_mut_ptr_set | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val, | | | | [yyjson_mut_doc](#structyyjson mut doc) * | doc ) |
Set value by a JSON pointer.
Parameters
| val | The target JSON value. | | ptr | The JSON pointer string (UTF-8 with null-terminator). | | new_val | The value to be set, pass NULL to remove. | | doc | Only used to create new values when needed. |
Returnstrue if JSON pointer is valid and new value is set, false otherwise. NoteThe parent nodes will be created if they do not exist. If the target value already exists, it will be replaced by the new value.
| yyjson_api_inline bool yyjson_mut_ptr_setn | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val, | | | | [yyjson_mut_doc](#structyyjson mut doc) * | doc ) |
Set value by a JSON pointer.
Parameters
| val | The target JSON value. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be set, pass NULL to remove. |
| doc | Only used to create new values when needed. |
Returnstrue if JSON pointer is valid and new value is set, false otherwise. NoteThe parent nodes will be created if they do not exist. If the target value already exists, it will be replaced by the new value.
| yyjson_api_inline bool yyjson_mut_ptr_setx | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val, | | | | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | bool | create_parent, | | | | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Set value by a JSON pointer.
Parameters
| val | The target JSON value. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be set, pass NULL to remove. |
| doc | Only used to create new values when needed. |
| create_parent | Whether to create parent nodes if not exist. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
Returnstrue if JSON pointer is valid and new value is set, false otherwise. NoteIf the target value already exists, it will be replaced by the new value.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_doc_ptr_replace | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val ) |
Replace value by a JSON pointer.
Parameters
| doc | The target JSON document. | | ptr | The JSON pointer string (UTF-8 with null-terminator). | | new_val | The new value to replace the old one. |
ReturnsThe old value that was replaced, or NULL if not found.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_doc_ptr_replacen | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val ) |
Replace value by a JSON pointer.
Parameters
| doc | The target JSON document. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The new value to replace the old one. |
ReturnsThe old value that was replaced, or NULL if not found.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_doc_ptr_replacex | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val, | | | | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Replace value by a JSON pointer.
Parameters
| doc | The target JSON document. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The new value to replace the old one. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
ReturnsThe old value that was replaced, or NULL if not found.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_ptr_replace | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val ) |
Replace value by a JSON pointer.
Parameters
| val | The target JSON value. | | ptr | The JSON pointer string (UTF-8 with null-terminator). | | new_val | The new value to replace the old one. |
ReturnsThe old value that was replaced, or NULL if not found.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_ptr_replacen | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val ) |
Replace value by a JSON pointer.
Parameters
| val | The target JSON value. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The new value to replace the old one. |
ReturnsThe old value that was replaced, or NULL if not found.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_ptr_replacex | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_mut_val](#structyyjson mut val) * | new_val, | | | | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Replace value by a JSON pointer.
Parameters
| val | The target JSON value. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The new value to replace the old one. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
ReturnsThe old value that was replaced, or NULL if not found.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_doc_ptr_remove | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr ) |
Remove value by a JSON pointer.
Parameters
| doc | The target JSON document. | | ptr | The JSON pointer string (UTF-8 with null-terminator). |
ReturnsThe removed value, or NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_doc_ptr_removen | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | size_t | len ) |
Remove value by a JSON pointer.
Parameters
| doc | The target JSON document. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
ReturnsThe removed value, or NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_doc_ptr_removex | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Remove value by a JSON pointer.
Parameters
| doc | The target JSON document. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
ReturnsThe removed value, or NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_ptr_remove | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr ) |
Remove value by a JSON pointer.
Parameters
| val | The target JSON value. | | ptr | The JSON pointer string (UTF-8 with null-terminator). |
ReturnsThe removed value, or NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_ptr_removen | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | size_t | len ) |
Remove value by a JSON pointer.
Parameters
| val | The target JSON value. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
ReturnsThe removed value, or NULL on error.
| yyjson_api_inline [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_ptr_removex | ( | [yyjson_mut_val](#structyyjson mut val) * | val, | | | | const char * | ptr, | | | | size_t | len, | | | | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_ptr_err](#structyyjson ptr err) * | err ) |
Remove value by a JSON pointer.
Parameters
| val | The target JSON value. |
| ptr | The JSON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
ReturnsThe removed value, or NULL on error.
| yyjson_api_inline bool yyjson_ptr_ctx_append | ( | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_mut_val](#structyyjson mut val) * | key, | | | | [yyjson_mut_val](#structyyjson mut val) * | val ) |
Append value by JSON pointer context.
Parameters
| ctx | The context from the yyjson_mut_ptr_xxx() calls. |
| key | New key if ctx->ctn is object, or NULL if ctx->ctn is array. |
| val | New value to be added. |
Returnstrue on success or false on fail.
| yyjson_api_inline bool yyjson_ptr_ctx_replace | ( | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx, | | | | [yyjson_mut_val](#structyyjson mut val) * | val ) |
Replace value by JSON pointer context.
Parameters
| ctx | The context from the yyjson_mut_ptr_xxx() calls. |
| val | New value to be replaced. |
Returnstrue on success or false on fail. NoteIf success, the old value will be returned via ctx->old.
| yyjson_api_inline bool yyjson_ptr_ctx_remove | ( | [yyjson_ptr_ctx](#structyyjson ptr ctx) * | ctx | ) | |
Remove value by JSON pointer context.
Parameters
| ctx | The context from the yyjson_mut_ptr_xxx() calls. |
Returnstrue on success or false on fail. NoteIf success, the old value will be returned via ctx->old.
| yyjson_api [yyjson_mut_val](#structyyjson mut val) * yyjson_patch | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | yyjson_val * | orig, | | | | yyjson_val * | patch, | | | | [yyjson_patch_err](#structyyjson patch err) * | err ) |
Creates and returns a patched JSON value (RFC 6902). The memory of the returned value is allocated by the doc. The err is used to receive error information, pass NULL if not needed. Returns NULL if the patch could not be applied.
| yyjson_api [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_patch | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | orig, | | | | [yyjson_mut_val](#structyyjson mut val) * | patch, | | | | [yyjson_patch_err](#structyyjson patch err) * | err ) |
Creates and returns a patched JSON value (RFC 6902). The memory of the returned value is allocated by the doc. The err is used to receive error information, pass NULL if not needed. Returns NULL if the patch could not be applied.
| yyjson_api [yyjson_mut_val](#structyyjson mut val) * yyjson_merge_patch | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | yyjson_val * | orig, | | | | yyjson_val * | patch ) |
Creates and returns a merge-patched JSON value (RFC 7386). The memory of the returned value is allocated by the doc. Returns NULL if the patch could not be applied.
WarningThis function is recursive and may cause a stack overflow if the object level is too deep.
| yyjson_api [yyjson_mut_val](#structyyjson mut val) * yyjson_mut_merge_patch | ( | [yyjson_mut_doc](#structyyjson mut doc) * | doc, | | | | [yyjson_mut_val](#structyyjson mut val) * | orig, | | | | [yyjson_mut_val](#structyyjson mut val) * | patch ) |
Creates and returns a merge-patched JSON value (RFC 7386). The memory of the returned value is allocated by the doc. Returns NULL if the patch could not be applied.
WarningThis function is recursive and may cause a stack overflow if the object level is too deep.
| yyjson_api_inline bool yyjson_ptr_get_bool | ( | yyjson_val * | root, | | | | const char * | ptr, | | | | bool * | value ) |
Set provided value if the JSON Pointer (RFC 6901) exists and is type bool. Returns true if value at ptr exists and is the correct type, otherwise false.
| yyjson_api_inline bool yyjson_ptr_get_uint | ( | yyjson_val * | root, | | | | const char * | ptr, | | | | uint64_t * | value ) |
Set provided value if the JSON Pointer (RFC 6901) exists and is an integer that fits in uint64_t. Returns true if successful, otherwise false.
| yyjson_api_inline bool yyjson_ptr_get_sint | ( | yyjson_val * | root, | | | | const char * | ptr, | | | | int64_t * | value ) |
Set provided value if the JSON Pointer (RFC 6901) exists and is an integer that fits in int64_t. Returns true if successful, otherwise false.
| yyjson_api_inline bool yyjson_ptr_get_real | ( | yyjson_val * | root, | | | | const char * | ptr, | | | | double * | value ) |
Set provided value if the JSON Pointer (RFC 6901) exists and is type real. Returns true if value at ptr exists and is the correct type, otherwise false.
| yyjson_api_inline bool yyjson_ptr_get_num | ( | yyjson_val * | root, | | | | const char * | ptr, | | | | double * | value ) |
Set provided value if the JSON Pointer (RFC 6901) exists and is type sint, uint or real. Returns true if value at ptr exists and is the correct type, otherwise false.
| yyjson_api_inline bool yyjson_ptr_get_str | ( | yyjson_val * | root, | | | | const char * | ptr, | | | | const char ** | value ) |
Set provided value if the JSON Pointer (RFC 6901) exists and is type string. Returns true if value at ptr exists and is the correct type, otherwise false.
| yyjson_deprecated | ( | "renamed to yyjson_doc_ptr_get" | | ) | |
**Deprecated**renamed to yyjson_doc_ptr_get
| yyjson_deprecated | ( | "renamed to yyjson_doc_ptr_getn" | | ) | |
**Deprecated**renamed to yyjson_doc_ptr_getn
| yyjson_deprecated | ( | "renamed to yyjson_mut_doc_ptr_get" | | ) | |
**Deprecated**renamed to yyjson_mut_doc_ptr_get
| yyjson_deprecated | ( | "renamed to yyjson_mut_doc_ptr_getn" | | ) | |
**Deprecated**renamed to yyjson_mut_doc_ptr_getn
| yyjson_deprecated | ( | "renamed to yyjson_ptr_get" | | ) | |
**Deprecated**renamed to yyjson_ptr_get
| yyjson_deprecated | ( | "renamed to yyjson_ptr_getn" | | ) | |
**Deprecated**renamed to yyjson_ptr_getn
| yyjson_deprecated | ( | "renamed to yyjson_mut_ptr_get" | | ) | |
**Deprecated**renamed to yyjson_mut_ptr_get
| yyjson_deprecated | ( | "renamed to yyjson_mut_ptr_getn" | | ) | |
**Deprecated**renamed to yyjson_mut_ptr_getn
| yyjson_deprecated | ( | "renamed to unsafe_yyjson_ptr_getn" | | ) | |
**Deprecated**renamed to yyjson_mut_ptr_getn
| yyjson_deprecated | ( | "renamed to unsafe_yyjson_mut_ptr_getx" | | ) | |
**Deprecated**renamed to unsafe_yyjson_mut_ptr_getx
|
| const yyjson_read_flag YYJSON_READ_NOFLAG = 0 |
| static |
Default option (RFC 8259 compliant):
|
| const yyjson_read_flag YYJSON_READ_INSITU = 1 << 0 |
| static |
Read the input data in-situ. This option allows the reader to modify and use input data to store string values, which can increase reading speed slightly. The caller should hold the input data before free the document. The input data must be padded by at least YYJSON_PADDING_SIZE bytes. For example: [1,2] should be [1,2]\0\0\0\0, input length should be 5.
|
| const yyjson_read_flag YYJSON_READ_STOP_WHEN_DONE = 1 << 1 |
| static |
Stop when done instead of issuing an error if there's additional content after a JSON document. This option may be used to parse small pieces of JSON in larger data, such as NDJSON.
|
| const yyjson_read_flag YYJSON_READ_ALLOW_TRAILING_COMMAS = 1 << 2 |
| static |
Allow single trailing comma at the end of an object or array, such as [1,2,3,], {"a":1,"b":2,} (non-standard).
|
| const yyjson_read_flag YYJSON_READ_ALLOW_COMMENTS = 1 << 3 |
| static |
Allow C-style single-line and mult-line comments (non-standard).
|
| const yyjson_read_flag YYJSON_READ_ALLOW_INF_AND_NAN = 1 << 4 |
| static |
Allow inf/nan number and literal, case-insensitive, such as 1e999, NaN, inf, -Infinity (non-standard).
|
| const yyjson_read_flag YYJSON_READ_NUMBER_AS_RAW = 1 << 5 |
| static |
Read all numbers as raw strings (value with YYJSON_TYPE_RAW type), inf/nan literal is also read as raw with ALLOW_INF_AND_NAN flag.
|
| const yyjson_read_flag YYJSON_READ_ALLOW_INVALID_UNICODE = 1 << 6 |
| static |
Allow reading invalid unicode when parsing string values (non-standard). Invalid characters will be allowed to appear in the string values, but invalid escape sequences will still be reported as errors. This flag does not affect the performance of correctly encoded strings.
WarningStrings in JSON values may contain incorrect encoding when this option is used, you need to handle these strings carefully to avoid security risks.
|
| const yyjson_read_flag YYJSON_READ_BIGNUM_AS_RAW = 1 << 7 |
| static |
Read big numbers as raw strings. These big numbers include integers that cannot be represented by int64_t and uint64_t, and floating-point numbers that cannot be represented by finite double. The flag will be overridden by YYJSON_READ_NUMBER_AS_RAW flag.
|
| const yyjson_read_flag YYJSON_READ_ALLOW_BOM = 1 << 8 |
| static |
Allow UTF-8 BOM and skip it before parsing if any (non-standard).
|
| const yyjson_read_flag YYJSON_READ_ALLOW_EXT_NUMBER = 1 << 9 |
| static |
Allow extended number formats (non-standard):
0x7B..123, 123..+123.|
| const yyjson_read_flag YYJSON_READ_ALLOW_EXT_ESCAPE = 1 << 10 |
| static |
Allow extended escape sequences in strings (non-standard):
\a, \e, \v, \', \?, \0.\xNN, such as \x7B.\1-\9 will still trigger an error.|
| const yyjson_read_flag YYJSON_READ_ALLOW_EXT_WHITESPACE = 1 << 11 |
| static |
Allow extended whitespace characters (non-standard):
\v and form feed \f.\u2028 and paragraph separator \u2029.\xA0.\uFEFF.|
| const yyjson_read_flag YYJSON_READ_ALLOW_SINGLE_QUOTED_STR = 1 << 12 |
| static |
Allow strings enclosed in single quotes (non-standard), such as 'ab'.
|
| const yyjson_read_flag YYJSON_READ_ALLOW_UNQUOTED_KEY = 1 << 13 |
| static |
Allow object keys without quotes (non-standard), such as {a:1,b:2}. This extends the ECMAScript IdentifierName rule by allowing any non-whitespace character with code point above U+007F.
|
| const yyjson_read_flag YYJSON_READ_JSON5 |
| static |
Initial value:
=
(1 << 2) |
(1 << 3) |
(1 << 4) |
(1 << 9) |
(1 << 10) |
(1 << 11) |
(1 << 12) |
(1 << 13)
Allow JSON5 format, see: [https://json5.org]. This flag supports all JSON5 features with some additional extensions:
\a, \e).NaN, Inf and Infinity literals.|
| const yyjson_read_code YYJSON_READ_SUCCESS = 0 |
| static |
Success, no error.
|
| const yyjson_read_code YYJSON_READ_ERROR_INVALID_PARAMETER = 1 |
| static |
Invalid parameter, such as NULL input string or 0 input length.
|
| const yyjson_read_code YYJSON_READ_ERROR_MEMORY_ALLOCATION = 2 |
| static |
Memory allocation failed.
|
| const yyjson_read_code YYJSON_READ_ERROR_EMPTY_CONTENT = 3 |
| static |
Input JSON string is empty.
|
| const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_CONTENT = 4 |
| static |
Unexpected content after document, such as [123]abc.
|
| const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_END = 5 |
| static |
Unexpected end of input, the parsed part is valid, such as [123.
|
| const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_CHARACTER = 6 |
| static |
Unexpected character inside the document, such as [abc].
|
| const yyjson_read_code YYJSON_READ_ERROR_JSON_STRUCTURE = 7 |
| static |
Invalid JSON structure, such as [1,].
|
| const yyjson_read_code YYJSON_READ_ERROR_INVALID_COMMENT = 8 |
| static |
Invalid comment, deprecated, use UNEXPECTED_END for unclosed comment.
|
| const yyjson_read_code YYJSON_READ_ERROR_INVALID_NUMBER = 9 |
| static |
Invalid number, such as 123.e12, 000.
|
| const yyjson_read_code YYJSON_READ_ERROR_INVALID_STRING = 10 |
| static |
Invalid string, such as invalid escaped character inside a string.
|
| const yyjson_read_code YYJSON_READ_ERROR_LITERAL = 11 |
| static |
Invalid JSON literal, such as truu.
|
| const yyjson_read_code YYJSON_READ_ERROR_FILE_OPEN = 12 |
| static |
Failed to open a file.
|
| const yyjson_read_code YYJSON_READ_ERROR_FILE_READ = 13 |
| static |
Failed to read a file.
|
| const yyjson_read_code YYJSON_READ_ERROR_MORE = 14 |
| static |
Incomplete input during incremental parsing; parsing state is preserved.
|
| const yyjson_write_flag YYJSON_WRITE_NOFLAG = 0 |
| static |
Default option:
|
| const yyjson_write_flag YYJSON_WRITE_PRETTY = 1 << 0 |
| static |
Write JSON pretty with 4 space indent.
|
| const yyjson_write_flag YYJSON_WRITE_ESCAPE_UNICODE = 1 << 1 |
| static |
Escape unicode as uXXXX, make the output ASCII only.
|
| const yyjson_write_flag YYJSON_WRITE_ESCAPE_SLASHES = 1 << 2 |
| static |
Escape '/' as '/'.
|
| const yyjson_write_flag YYJSON_WRITE_ALLOW_INF_AND_NAN = 1 << 3 |
| static |
Write inf and nan number as 'Infinity' and 'NaN' literal (non-standard).
|
| const yyjson_write_flag YYJSON_WRITE_INF_AND_NAN_AS_NULL = 1 << 4 |
| static |
Write inf and nan number as null literal. This flag will override YYJSON_WRITE_ALLOW_INF_AND_NAN flag.
|
| const yyjson_write_flag YYJSON_WRITE_ALLOW_INVALID_UNICODE = 1 << 5 |
| static |
Allow invalid unicode when encoding string values (non-standard). Invalid characters in string value will be copied byte by byte. If YYJSON_WRITE_ESCAPE_UNICODE flag is also set, invalid character will be escaped as U+FFFD (replacement character). This flag does not affect the performance of correctly encoded strings.
|
| const yyjson_write_flag YYJSON_WRITE_PRETTY_TWO_SPACES = 1 << 6 |
| static |
Write JSON pretty with 2 space indent. This flag will override YYJSON_WRITE_PRETTY flag.
|
| const yyjson_write_flag YYJSON_WRITE_NEWLINE_AT_END = 1 << 7 |
| static |
Adds a newline character \n at the end of the JSON. This can be helpful for text editors or NDJSON.
|
| const yyjson_write_code YYJSON_WRITE_SUCCESS = 0 |
| static |
Success, no error.
|
| const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_PARAMETER = 1 |
| static |
Invalid parameter, such as NULL document.
|
| const yyjson_write_code YYJSON_WRITE_ERROR_MEMORY_ALLOCATION = 2 |
| static |
Memory allocation failure occurs.
|
| const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_VALUE_TYPE = 3 |
| static |
Invalid value type in JSON document.
|
| const yyjson_write_code YYJSON_WRITE_ERROR_NAN_OR_INF = 4 |
| static |
NaN or Infinity number occurs.
|
| const yyjson_write_code YYJSON_WRITE_ERROR_FILE_OPEN = 5 |
| static |
Failed to open a file.
|
| const yyjson_write_code YYJSON_WRITE_ERROR_FILE_WRITE = 6 |
| static |
Failed to write a file.
|
| const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_STRING = 7 |
| static |
Invalid unicode in string.
|
| const yyjson_ptr_code YYJSON_PTR_ERR_NONE = 0 |
| static |
No JSON pointer error.
|
| const yyjson_ptr_code YYJSON_PTR_ERR_PARAMETER = 1 |
| static |
Invalid input parameter, such as NULL input.
|
| const yyjson_ptr_code YYJSON_PTR_ERR_SYNTAX = 2 |
| static |
JSON pointer syntax error, such as invalid escape, token no prefix.
|
| const yyjson_ptr_code YYJSON_PTR_ERR_RESOLVE = 3 |
| static |
JSON pointer resolve failed, such as index out of range, key not found.
|
| const yyjson_ptr_code YYJSON_PTR_ERR_NULL_ROOT = 4 |
| static |
Document's root is NULL, but it is required for the function call.
|
| const yyjson_ptr_code YYJSON_PTR_ERR_SET_ROOT = 5 |
| static |
Cannot set root as the target is not a document.
|
| const yyjson_ptr_code YYJSON_PTR_ERR_MEMORY_ALLOCATION = 6 |
| static |
The memory allocation failed and a new value could not be created.
|
| const yyjson_patch_code YYJSON_PATCH_SUCCESS = 0 |
| static |
Success, no error.
|
| const yyjson_patch_code YYJSON_PATCH_ERROR_INVALID_PARAMETER = 1 |
| static |
Invalid parameter, such as NULL input or non-array patch.
|
| const yyjson_patch_code YYJSON_PATCH_ERROR_MEMORY_ALLOCATION = 2 |
| static |
Memory allocation failure occurs.
|
| const yyjson_patch_code YYJSON_PATCH_ERROR_INVALID_OPERATION = 3 |
| static |
JSON patch operation is not object type.
|
| const yyjson_patch_code YYJSON_PATCH_ERROR_MISSING_KEY = 4 |
| static |
JSON patch operation is missing a required key.
|
| const yyjson_patch_code YYJSON_PATCH_ERROR_INVALID_MEMBER = 5 |
| static |
JSON patch operation member is invalid.
|
| const yyjson_patch_code YYJSON_PATCH_ERROR_EQUAL = 6 |
| static |
JSON patch operation test not equal.
|
| const yyjson_patch_code YYJSON_PATCH_ERROR_POINTER = 7 |
| static |
JSON patch operation failed on JSON pointer.