yyjson: yyjson.h File Reference

yyjson 0.10.0 A high performance C JSON library.

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>`

## Data Structures
struct | yyjson_alc
struct | yyjson_read_err
struct | yyjson_write_err
struct | yyjson_arr_iter
struct | yyjson_obj_iter
struct | yyjson_mut_arr_iter
struct | yyjson_mut_obj_iter
struct | yyjson_ptr_err
struct | yyjson_ptr_ctx
struct | yyjson_patch_err
union | yyjson_val_uni
struct | yyjson_val
struct | yyjson_doc
struct | yyjson_mut_val
struct | yyjson_str_chunk
struct | yyjson_str_pool
struct | yyjson_val_chunk
struct | yyjson_val_pool
struct | yyjson_mut_doc

## Macros
#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) 0
#define | yyjson_has_attribute(x) 0
#define | yyjson_has_feature(x) 0
#define | yyjson_has_include(x) 0
#define | yyjson_inline
#define | yyjson_noinline
#define | yyjson_align(x)
#define | yyjson_likely(expr) (expr)
#define | yyjson_unlikely(expr) (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 10
#define | YYJSON_VERSION_PATCH 0
#define | YYJSON_VERSION_HEX 0x000A00
#define | YYJSON_VERSION_STRING "0.10.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_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)

## Typedefs
typedef uint8_t | yyjson_type
typedef uint8_t | yyjson_subtype
typedef uint32_t | yyjson_read_flag
typedef uint32_t | yyjson_read_code
typedef uint32_t | yyjson_write_flag
typedef uint32_t | yyjson_write_code
typedef uint32_t | yyjson_ptr_code
typedef uint32_t | yyjson_patch_code

## Functions
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 *err)
yyjson_api yyjson_doc * | yyjson_read_file (const char *path, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)
yyjson_api yyjson_doc * | yyjson_read_fp (FILE *fp, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)
yyjson_api_inline yyjson_doc * | yyjson_read (const char *dat, size_t len, yyjson_read_flag flg)
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 *err)
yyjson_api_inline const char * | yyjson_mut_read_number (const char *dat, yyjson_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 *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 *err)
yyjson_api bool | yyjson_write_fp (FILE *fp, const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_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 *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 *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 *doc, yyjson_write_flag flg, const yyjson_alc *alc, yyjson_write_err *err)
yyjson_api_inline char * | yyjson_mut_write (const yyjson_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 *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 *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 *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 *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 *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 *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 *val, yyjson_write_flag flg, size_t *len)
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_real (yyjson_val *val, double num)
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 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 | yyjson_arr_iter_with (yyjson_val *arr)
yyjson_api_inline bool | yyjson_arr_iter_has_next (yyjson_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 | yyjson_obj_iter_with (yyjson_val *obj)
yyjson_api_inline bool | yyjson_obj_iter_has_next (yyjson_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 * | yyjson_mut_doc_get_root (yyjson_mut_doc *doc)
yyjson_api_inline void | yyjson_mut_doc_set_root (yyjson_mut_doc *doc, yyjson_mut_val *root)
yyjson_api bool | yyjson_mut_doc_set_str_pool_size (yyjson_mut_doc *doc, size_t len)
yyjson_api bool | yyjson_mut_doc_set_val_pool_size (yyjson_mut_doc *doc, size_t count)
yyjson_api void | yyjson_mut_doc_free (yyjson_mut_doc *doc)
yyjson_api yyjson_mut_doc * | yyjson_mut_doc_new (const yyjson_alc *alc)
yyjson_api yyjson_mut_doc * | yyjson_doc_mut_copy (yyjson_doc *doc, const yyjson_alc *alc)
yyjson_api yyjson_mut_doc * | yyjson_mut_doc_mut_copy (yyjson_mut_doc *doc, const yyjson_alc *alc)
yyjson_api yyjson_mut_val * | yyjson_val_mut_copy (yyjson_mut_doc *doc, yyjson_val *val)
yyjson_api yyjson_mut_val * | yyjson_mut_val_mut_copy (yyjson_mut_doc *doc, yyjson_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 *val)
yyjson_api_inline bool | yyjson_mut_is_null (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_true (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_false (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_bool (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_uint (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_sint (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_int (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_real (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_num (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_str (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_arr (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_obj (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_is_ctn (yyjson_mut_val *val)
yyjson_api_inline yyjson_type | yyjson_mut_get_type (yyjson_mut_val *val)
yyjson_api_inline yyjson_subtype | yyjson_mut_get_subtype (yyjson_mut_val *val)
yyjson_api_inline uint8_t | yyjson_mut_get_tag (yyjson_mut_val *val)
yyjson_api_inline const char * | yyjson_mut_get_type_desc (yyjson_mut_val *val)
yyjson_api_inline const char * | yyjson_mut_get_raw (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_get_bool (yyjson_mut_val *val)
yyjson_api_inline uint64_t | yyjson_mut_get_uint (yyjson_mut_val *val)
yyjson_api_inline int64_t | yyjson_mut_get_sint (yyjson_mut_val *val)
yyjson_api_inline int | yyjson_mut_get_int (yyjson_mut_val *val)
yyjson_api_inline double | yyjson_mut_get_real (yyjson_mut_val *val)
yyjson_api_inline double | yyjson_mut_get_num (yyjson_mut_val *val)
yyjson_api_inline const char * | yyjson_mut_get_str (yyjson_mut_val *val)
yyjson_api_inline size_t | yyjson_mut_get_len (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_equals_str (yyjson_mut_val *val, const char *str)
yyjson_api_inline bool | yyjson_mut_equals_strn (yyjson_mut_val *val, const char *str, size_t len)
yyjson_api_inline bool | yyjson_mut_equals (yyjson_mut_val *lhs, yyjson_mut_val *rhs)
yyjson_api_inline bool | yyjson_mut_set_raw (yyjson_mut_val *val, const char *raw, size_t len)
yyjson_api_inline bool | yyjson_mut_set_null (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_set_bool (yyjson_mut_val *val, bool num)
yyjson_api_inline bool | yyjson_mut_set_uint (yyjson_mut_val *val, uint64_t num)
yyjson_api_inline bool | yyjson_mut_set_sint (yyjson_mut_val *val, int64_t num)
yyjson_api_inline bool | yyjson_mut_set_int (yyjson_mut_val *val, int num)
yyjson_api_inline bool | yyjson_mut_set_real (yyjson_mut_val *val, double num)
yyjson_api_inline bool | yyjson_mut_set_str (yyjson_mut_val *val, const char *str)
yyjson_api_inline bool | yyjson_mut_set_strn (yyjson_mut_val *val, const char *str, size_t len)
yyjson_api_inline bool | yyjson_mut_set_arr (yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_set_obj (yyjson_mut_val *val)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_raw (yyjson_mut_doc *doc, const char *str)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_rawn (yyjson_mut_doc *doc, const char *str, size_t len)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_rawcpy (yyjson_mut_doc *doc, const char *str)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_rawncpy (yyjson_mut_doc *doc, const char *str, size_t len)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_null (yyjson_mut_doc *doc)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_true (yyjson_mut_doc *doc)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_false (yyjson_mut_doc *doc)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_bool (yyjson_mut_doc *doc, bool val)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_uint (yyjson_mut_doc *doc, uint64_t num)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_sint (yyjson_mut_doc *doc, int64_t num)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_int (yyjson_mut_doc *doc, int64_t num)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_real (yyjson_mut_doc *doc, double num)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_str (yyjson_mut_doc *doc, const char *str)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_strn (yyjson_mut_doc *doc, const char *str, size_t len)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_strcpy (yyjson_mut_doc *doc, const char *str)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_strncpy (yyjson_mut_doc *doc, const char *str, size_t len)
yyjson_api_inline size_t | yyjson_mut_arr_size (yyjson_mut_val *arr)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_get (yyjson_mut_val *arr, size_t idx)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_get_first (yyjson_mut_val *arr)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_get_last (yyjson_mut_val *arr)
yyjson_api_inline bool | yyjson_mut_arr_iter_init (yyjson_mut_val *arr, yyjson_mut_arr_iter *iter)
yyjson_api_inline yyjson_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 *iter)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_iter_next (yyjson_mut_arr_iter *iter)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_iter_remove (yyjson_mut_arr_iter *iter)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr (yyjson_mut_doc *doc)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_bool (yyjson_mut_doc *doc, const bool *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_sint (yyjson_mut_doc *doc, const int64_t *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_uint (yyjson_mut_doc *doc, const uint64_t *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_real (yyjson_mut_doc *doc, const double *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_sint8 (yyjson_mut_doc *doc, const int8_t *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_sint16 (yyjson_mut_doc *doc, const int16_t *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_sint32 (yyjson_mut_doc *doc, const int32_t *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_sint64 (yyjson_mut_doc *doc, const int64_t *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_uint8 (yyjson_mut_doc *doc, const uint8_t *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_uint16 (yyjson_mut_doc *doc, const uint16_t *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_uint32 (yyjson_mut_doc *doc, const uint32_t *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_uint64 (yyjson_mut_doc *doc, const uint64_t *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_float (yyjson_mut_doc *doc, const float *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_double (yyjson_mut_doc *doc, const double *vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_str (yyjson_mut_doc *doc, const char **vals, size_t count)
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)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_strcpy (yyjson_mut_doc *doc, const char **vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_with_strncpy (yyjson_mut_doc *doc, const char **vals, const size_t *lens, size_t count)
yyjson_api_inline bool | yyjson_mut_arr_insert (yyjson_mut_val *arr, yyjson_mut_val *val, size_t idx)
yyjson_api_inline bool | yyjson_mut_arr_append (yyjson_mut_val *arr, yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_arr_prepend (yyjson_mut_val *arr, yyjson_mut_val *val)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_replace (yyjson_mut_val *arr, size_t idx, yyjson_mut_val *val)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_remove (yyjson_mut_val *arr, size_t idx)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_remove_first (yyjson_mut_val *arr)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_remove_last (yyjson_mut_val *arr)
yyjson_api_inline bool | yyjson_mut_arr_remove_range (yyjson_mut_val *arr, size_t idx, size_t len)
yyjson_api_inline bool | yyjson_mut_arr_clear (yyjson_mut_val *arr)
yyjson_api_inline bool | yyjson_mut_arr_rotate (yyjson_mut_val *arr, size_t idx)
yyjson_api_inline bool | yyjson_mut_arr_add_val (yyjson_mut_val *arr, yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_arr_add_null (yyjson_mut_doc *doc, yyjson_mut_val *arr)
yyjson_api_inline bool | yyjson_mut_arr_add_true (yyjson_mut_doc *doc, yyjson_mut_val *arr)
yyjson_api_inline bool | yyjson_mut_arr_add_false (yyjson_mut_doc *doc, yyjson_mut_val *arr)
yyjson_api_inline bool | yyjson_mut_arr_add_bool (yyjson_mut_doc *doc, yyjson_mut_val *arr, bool val)
yyjson_api_inline bool | yyjson_mut_arr_add_uint (yyjson_mut_doc *doc, yyjson_mut_val *arr, uint64_t num)
yyjson_api_inline bool | yyjson_mut_arr_add_sint (yyjson_mut_doc *doc, yyjson_mut_val *arr, int64_t num)
yyjson_api_inline bool | yyjson_mut_arr_add_int (yyjson_mut_doc *doc, yyjson_mut_val *arr, int64_t num)
yyjson_api_inline bool | yyjson_mut_arr_add_real (yyjson_mut_doc *doc, yyjson_mut_val *arr, double num)
yyjson_api_inline bool | yyjson_mut_arr_add_str (yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str)
yyjson_api_inline bool | yyjson_mut_arr_add_strn (yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str, size_t len)
yyjson_api_inline bool | yyjson_mut_arr_add_strcpy (yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str)
yyjson_api_inline bool | yyjson_mut_arr_add_strncpy (yyjson_mut_doc *doc, yyjson_mut_val *arr, const char *str, size_t len)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_add_arr (yyjson_mut_doc *doc, yyjson_mut_val *arr)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_arr_add_obj (yyjson_mut_doc *doc, yyjson_mut_val *arr)
yyjson_api_inline size_t | yyjson_mut_obj_size (yyjson_mut_val *obj)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_get (yyjson_mut_val *obj, const char *key)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_getn (yyjson_mut_val *obj, const char *key, size_t key_len)
yyjson_api_inline bool | yyjson_mut_obj_iter_init (yyjson_mut_val *obj, yyjson_mut_obj_iter *iter)
yyjson_api_inline yyjson_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 *iter)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_iter_next (yyjson_mut_obj_iter *iter)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_iter_get_val (yyjson_mut_val *key)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_iter_remove (yyjson_mut_obj_iter *iter)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_iter_get (yyjson_mut_obj_iter *iter, const char *key)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_iter_getn (yyjson_mut_obj_iter *iter, const char *key, size_t key_len)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj (yyjson_mut_doc *doc)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_with_str (yyjson_mut_doc *doc, const char **keys, const char **vals, size_t count)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_with_kv (yyjson_mut_doc *doc, const char **kv_pairs, size_t pair_count)
yyjson_api_inline bool | yyjson_mut_obj_add (yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_obj_put (yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_obj_insert (yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val, size_t idx)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_remove (yyjson_mut_val *obj, yyjson_mut_val *key)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_remove_key (yyjson_mut_val *obj, const char *key)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_remove_keyn (yyjson_mut_val *obj, const char *key, size_t key_len)
yyjson_api_inline bool | yyjson_mut_obj_clear (yyjson_mut_val *obj)
yyjson_api_inline bool | yyjson_mut_obj_replace (yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_mut_obj_rotate (yyjson_mut_val *obj, size_t idx)
yyjson_api_inline bool | yyjson_mut_obj_add_null (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key)
yyjson_api_inline bool | yyjson_mut_obj_add_true (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key)
yyjson_api_inline bool | yyjson_mut_obj_add_false (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key)
yyjson_api_inline bool | yyjson_mut_obj_add_bool (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, bool val)
yyjson_api_inline bool | yyjson_mut_obj_add_uint (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, uint64_t val)
yyjson_api_inline bool | yyjson_mut_obj_add_sint (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, int64_t val)
yyjson_api_inline bool | yyjson_mut_obj_add_int (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, int64_t val)
yyjson_api_inline bool | yyjson_mut_obj_add_real (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, double val)
yyjson_api_inline bool | yyjson_mut_obj_add_str (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val)
yyjson_api_inline bool | yyjson_mut_obj_add_strn (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val, size_t len)
yyjson_api_inline bool | yyjson_mut_obj_add_strcpy (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val)
yyjson_api_inline bool | yyjson_mut_obj_add_strncpy (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *val, size_t len)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_add_arr (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_add_obj (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key)
yyjson_api_inline bool | yyjson_mut_obj_add_val (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, yyjson_mut_val *val)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_remove_str (yyjson_mut_val *obj, const char *key)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_obj_remove_strn (yyjson_mut_val *obj, const char *key, size_t len)
yyjson_api_inline bool | yyjson_mut_obj_rename_key (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, const char *new_key)
yyjson_api_inline bool | yyjson_mut_obj_rename_keyn (yyjson_mut_doc *doc, yyjson_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 *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 *err)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_doc_ptr_get (yyjson_mut_doc *doc, const char *ptr)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_doc_ptr_getn (yyjson_mut_doc *doc, const char *ptr, size_t len)
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)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_ptr_get (yyjson_mut_val *val, const char *ptr)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_ptr_getn (yyjson_mut_val *val, const char *ptr, size_t len)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_ptr_getx (yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api_inline bool | yyjson_mut_doc_ptr_add (yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val)
yyjson_api_inline bool | yyjson_mut_doc_ptr_addn (yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val)
yyjson_api_inline bool | yyjson_mut_doc_ptr_addx (yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api_inline bool | yyjson_mut_ptr_add (yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val, yyjson_mut_doc *doc)
yyjson_api_inline bool | yyjson_mut_ptr_addn (yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc)
yyjson_api_inline bool | yyjson_mut_ptr_addx (yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api_inline bool | yyjson_mut_doc_ptr_set (yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val)
yyjson_api_inline bool | yyjson_mut_doc_ptr_setn (yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val)
yyjson_api_inline bool | yyjson_mut_doc_ptr_setx (yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api_inline bool | yyjson_mut_ptr_set (yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val, yyjson_mut_doc *doc)
yyjson_api_inline bool | yyjson_mut_ptr_setn (yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc)
yyjson_api_inline bool | yyjson_mut_ptr_setx (yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_doc_ptr_replace (yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_doc_ptr_replacen (yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_doc_ptr_replacex (yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_ptr_replace (yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_ptr_replacen (yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_ptr_replacex (yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_doc_ptr_remove (yyjson_mut_doc *doc, const char *ptr)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_doc_ptr_removen (yyjson_mut_doc *doc, const char *ptr, size_t len)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_doc_ptr_removex (yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_ptr_remove (yyjson_mut_val *val, const char *ptr)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_ptr_removen (yyjson_mut_val *val, const char *ptr, size_t len)
yyjson_api_inline yyjson_mut_val * | yyjson_mut_ptr_removex (yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api_inline bool | yyjson_ptr_ctx_append (yyjson_ptr_ctx *ctx, yyjson_mut_val *key, yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_ptr_ctx_replace (yyjson_ptr_ctx *ctx, yyjson_mut_val *val)
yyjson_api_inline bool | yyjson_ptr_ctx_remove (yyjson_ptr_ctx *ctx)
yyjson_api yyjson_mut_val * | yyjson_patch (yyjson_mut_doc *doc, yyjson_val *orig, yyjson_val *patch, yyjson_patch_err *err)
yyjson_api yyjson_mut_val * | yyjson_mut_patch (yyjson_mut_doc *doc, yyjson_mut_val *orig, yyjson_mut_val *patch, yyjson_patch_err *err)
yyjson_api yyjson_mut_val * | yyjson_merge_patch (yyjson_mut_doc *doc, yyjson_val *orig, yyjson_val *patch)
yyjson_api yyjson_mut_val * | yyjson_mut_merge_patch (yyjson_mut_doc *doc, yyjson_mut_val *orig, yyjson_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 *yyjson_mut_doc_get_pointer(yyjson_mut_doc *doc
| yyjson_deprecated ("renamed to yyjson_mut_doc_ptr_getn") yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_get_pointern(yyjson_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 *yyjson_mut_get_pointer(yyjson_mut_val *val
| yyjson_deprecated ("renamed to yyjson_mut_ptr_getn") yyjson_api_inline yyjson_mut_val *yyjson_mut_get_pointern(yyjson_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 *unsafe_yyjson_mut_get_pointer(yyjson_mut_val *val

## Variables
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_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_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

## Detailed Description

Date
  2019-03-09

Author
  YaoYuan

## Data Structure Documentation

## ◆ yyjson_read_err

struct yyjson_read_err

Error information for JSON reader.

Data Fields
yyjson_read_code | 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).

## ◆ yyjson_write_err

struct yyjson_write_err

Error information for JSON writer.

Data Fields
yyjson_write_code | code | Error code, see `yyjson_write_code` for all possible values.
const char * | msg | Error message, constant, no need to free (NULL if success).

## ◆ yyjson_arr_iter

struct yyjson_arr_iter

A JSON array iterator.

Example
  yyjson_val *val;
  yyjson_arr_iter iter = yyjson_arr_iter_with(arr);
  while ((val = yyjson_arr_iter_next(&iter))) {
  your_func(val);
  }
  yyjson_arr_iter_with
  yyjson_api_inline yyjson_arr_iter yyjson_arr_iter_with(yyjson_val *arr)
  Definition: yyjson.h:5143
  yyjson_arr_iter_next
  yyjson_api_inline yyjson_val * yyjson_arr_iter_next(yyjson_arr_iter *iter)
  Definition: yyjson.h:5153
  yyjson_arr_iter
  Definition: yyjson.h:1828
  yyjson_val
  Definition: yyjson.h:4514

Data Fields
yyjson_val * | cur | next value
size_t | idx | next value's index
size_t | max | maximum index (arr.size)

## ◆ yyjson_obj_iter

struct yyjson_obj_iter

A JSON object iterator.

Example
  yyjson_val *key, *val;
  yyjson_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_obj_iter_get_val
  yyjson_api_inline yyjson_val * yyjson_obj_iter_get_val(yyjson_val *key)
  Definition: yyjson.h:5232
  yyjson_obj_iter_with
  yyjson_api_inline yyjson_obj_iter yyjson_obj_iter_with(yyjson_val *obj)
  Definition: yyjson.h:5212
  yyjson_obj_iter_next
  yyjson_api_inline yyjson_val * yyjson_obj_iter_next(yyjson_obj_iter *iter)
  Definition: yyjson.h:5222
  yyjson_obj_iter::obj
  yyjson_val * obj
  Definition: yyjson.h:1956
  yyjson_obj_iter
  Definition: yyjson.h:1952

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 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_obj_iter_get
yyjson_api_inline yyjson_val * yyjson_obj_iter_get(yyjson_obj_iter *iter, const char *key)
Definition: yyjson.h:5236

See also
  yyjson_obj_iter_get() and yyjson_obj_iter_getn()

Data Fields
yyjson_val * | cur | next key
size_t | idx | next key's index
size_t | max | maximum key index (obj.size)
yyjson_val * | obj | the object being iterated

## ◆ yyjson_mut_arr_iter

struct yyjson_mut_arr_iter

A mutable JSON array iterator.

Warning
  You 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 *val;
  yyjson_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_mut_arr_iter_remove
  yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_iter_remove(yyjson_mut_arr_iter *iter)
  Definition: yyjson.h:5889
  yyjson_mut_arr_iter_next
  yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_iter_next(yyjson_mut_arr_iter *iter)
  Definition: yyjson.h:5877
  yyjson_mut_arr_iter_with
  yyjson_api_inline yyjson_mut_arr_iter yyjson_mut_arr_iter_with(yyjson_mut_val *arr)
  Definition: yyjson.h:5866
  yyjson_mut_arr_iter::arr
  yyjson_mut_val * arr
  Definition: yyjson.h:2513
  yyjson_mut_arr_iter
  Definition: yyjson.h:2508
  yyjson_mut_val
  Definition: yyjson.h:5281

Data Fields
yyjson_mut_val * | arr | the array being iterated
yyjson_mut_val * | cur | current value
size_t | idx | next value's index
size_t | max | maximum index (arr.size)
yyjson_mut_val * | pre | previous value

## ◆ yyjson_mut_obj_iter

struct yyjson_mut_obj_iter

A mutable JSON object iterator.

Warning
  You 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 *key, *val;
  yyjson_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_mut_obj_iter_next
  yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_next(yyjson_mut_obj_iter *iter)
  Definition: yyjson.h:6513
  yyjson_mut_obj_iter_remove
  yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_remove(yyjson_mut_obj_iter *iter)
  Definition: yyjson.h:6530
  yyjson_mut_obj_iter_get_val
  yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_get_val(yyjson_mut_val *key)
  Definition: yyjson.h:6525
  yyjson_mut_obj_iter::obj
  yyjson_mut_val * obj
  Definition: yyjson.h:3315
  yyjson_mut_obj_iter_with
  yyjson_api_inline yyjson_mut_obj_iter yyjson_mut_obj_iter_with(yyjson_mut_val *obj)
  Definition: yyjson.h:6502
  yyjson_mut_obj_iter
  Definition: yyjson.h:3310

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 *key, *val;
yyjson_mut_obj_iter iter = yyjson_mut_obj_iter_with(obj);
yyjson_mut_val *v1 = yyjson_mut_obj_iter_get(&iter, "k1");
yyjson_mut_val *v3 = yyjson_mut_obj_iter_get(&iter, "k3");
yyjson_mut_obj_iter_get
yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_get(yyjson_mut_obj_iter *iter, const char *key)
Definition: yyjson.h:6547

See also
  `yyjson_mut_obj_iter_get()` and `yyjson_mut_obj_iter_getn()`

Data Fields
yyjson_mut_val * | cur | current key
size_t | idx | next key's index
size_t | max | maximum key index (obj.size)
yyjson_mut_val * | obj | the object being iterated
yyjson_mut_val * | pre | previous key

## ◆ yyjson_ptr_err

struct yyjson_ptr_err

Error information for JSON pointer.

Data Fields
yyjson_ptr_code | 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).

## ◆ yyjson_ptr_ctx

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_mut_doc_ptr_getx
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:7199
yyjson_is_null
yyjson_api_inline bool yyjson_is_null(yyjson_val *val)
Definition: yyjson.h:4870
yyjson_ptr_ctx_remove
yyjson_api_inline bool yyjson_ptr_ctx_remove(yyjson_ptr_ctx *ctx)
Definition: yyjson.h:7705

Data Fields
yyjson_mut_val * | ctn | 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 * | 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.
yyjson_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_patch_err

struct yyjson_patch_err

Error information for JSON patch.

Data Fields
yyjson_patch_code | 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 | ptr | JSON pointer error if `code == YYJSON_PATCH_ERROR_POINTER`.

## ◆ yyjson_val_uni

union yyjson_val_uni

Payload of a JSON value (8 bytes).

## ◆ yyjson_val

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 | tag | type, subtype and length
yyjson_val_uni | uni | payload

## ◆ yyjson_doc

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_alc | alc | Allocator used by document (nonnull).
size_t | dat_read | The total number of bytes read when parsing JSON (nonzero).
yyjson_val * | root | Root value of the document (nonnull).
char * | str_pool | The string pool used by JSON values (nullable).
size_t | val_read | The total number of value read when parsing JSON (nonzero).

## ◆ yyjson_mut_val

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
yyjson_mut_val * | next | the next value in circular linked list
uint64_t | tag | type, subtype and length
yyjson_val_uni | uni | payload

## ◆ yyjson_str_chunk

struct yyjson_str_chunk

A memory chunk in string memory pool.

## ◆ yyjson_str_pool

struct yyjson_str_pool

A memory pool to hold all strings in a mutable document.

## ◆ yyjson_val_chunk

struct yyjson_val_chunk

A memory chunk in value memory pool. `sizeof(yyjson_val_chunk)` should not larger than `sizeof(yyjson_mut_val)`.

## ◆ yyjson_val_pool

struct yyjson_val_pool

A memory pool to hold all values in a mutable document.

## ◆ yyjson_mut_doc

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_alc | alc | a valid allocator, nonnull
yyjson_mut_val * | root | root value of the JSON document, nullable
yyjson_str_pool | str_pool | string memory pool
yyjson_val_pool | val_pool | value memory pool

## Macro Definition Documentation

## ◆ __bool_true_false_are_defined

#define __bool_true_false_are_defined 1

stdint (C89 compatible) stdbool (C89 compatible)

## ◆ yyjson_align

#define yyjson_align | ( |  | x | ) |

align for compiler

## ◆ yyjson_api

#define yyjson_api

function export

## ◆ yyjson_api_inline

#define yyjson_api_inline static yyjson_inline

inline function export

## ◆ yyjson_arr_foreach

#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_arr_size
yyjson_api_inline size_t yyjson_arr_size(yyjson_val *arr)
Definition: yyjson.h:5081
yyjson_arr_get_first
yyjson_api_inline yyjson_val * yyjson_arr_get_first(yyjson_val *arr)
Definition: yyjson.h:5100

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);
  }
  yyjson_arr_foreach
  #define yyjson_arr_foreach(arr, idx, max, val)
  Definition: yyjson.h:1884

## ◆ YYJSON_CPP_VER

#define YYJSON_CPP_VER 0

C++ version

## ◆ yyjson_deprecated

#define yyjson_deprecated | ( |  | msg | ) |

deprecate warning

## ◆ YYJSON_GCC_VER

#define YYJSON_GCC_VER 0

compiler version (GCC)

## ◆ yyjson_has_attribute

#define yyjson_has_attribute | ( |  | x | ) | 0

compiler attribute check (since gcc 5.0, clang 2.9, icc 17)

## ◆ yyjson_has_builtin

#define yyjson_has_builtin | ( |  | x | ) | 0

compiler builtin check (since gcc 10.0, clang 2.6, icc 2021)

## ◆ YYJSON_HAS_CONSTANT_P

#define YYJSON_HAS_CONSTANT_P 0

compile-time constant check for compiler

## ◆ yyjson_has_feature

#define yyjson_has_feature | ( |  | x | ) | 0

compiler feature check (since clang 2.6, icc 17)

## ◆ yyjson_has_include

#define yyjson_has_include | ( |  | x | ) | 0

include check (since gcc 5.0, clang 2.7, icc 16, msvc 2017 15.3)

## ◆ yyjson_inline

#define yyjson_inline

inline for compiler

## ◆ YYJSON_IS_REAL_GCC

#define YYJSON_IS_REAL_GCC 0

real gcc check

## ◆ yyjson_likely

#define yyjson_likely | ( |  | expr | ) | (expr)

likely for compiler

## ◆ YYJSON_MSC_VER

#define YYJSON_MSC_VER 0

compiler version (MSVC)

## ◆ yyjson_mut_arr_foreach

#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_arr_size
yyjson_api_inline size_t yyjson_mut_arr_size(yyjson_mut_val *arr)
Definition: yyjson.h:5816
yyjson_mut_arr_get_first
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_get_first(yyjson_mut_val *arr)
Definition: yyjson.h:5830

Macro for iterating over an array. It works like iterator, but with a more intuitive API.

Warning
  You should not modify the array while iterating over it.

Example
  size_t idx, max;
  yyjson_mut_val *val;
  yyjson_mut_arr_foreach(arr, idx, max, val) {
  your_func(idx, val);
  }
  yyjson_mut_arr_foreach
  #define yyjson_mut_arr_foreach(arr, idx, max, val)
  Definition: yyjson.h:2578

## ◆ yyjson_mut_obj_foreach

#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 *)(obj)->uni.ptr)->next->next : NULL, \
(val) = (key) ? (key)->next : NULL; \
(idx) < (max); \
(idx)++, \
(key) = (val)->next, \
(val) = (key)->next)
yyjson_mut_obj_size
yyjson_api_inline size_t yyjson_mut_obj_size(yyjson_mut_val *obj)
Definition: yyjson.h:6459

Macro for iterating over an object. It works like iterator, but with a more intuitive API.

Warning
  You should not modify the object while iterating over it.

Example
  size_t idx, max;
  yyjson_val *key, *val;
  yyjson_obj_foreach(obj, idx, max, key, val) {
  your_func(key, val);
  }
  yyjson_obj_foreach
  #define yyjson_obj_foreach(obj, idx, max, key, val)
  Definition: yyjson.h:2055

## ◆ yyjson_noinline

#define yyjson_noinline

noinline for compiler

## ◆ yyjson_obj_foreach

#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_obj_size
yyjson_api_inline size_t yyjson_obj_size(yyjson_val *obj)
Definition: yyjson.h:5170

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);
  }

## ◆ YYJSON_PADDING_SIZE

#define YYJSON_PADDING_SIZE 4

Padding size for JSON reader.

## ◆ YYJSON_RESERVED_BIT

#define YYJSON_RESERVED_BIT ((uint8_t)3)

The number of reserved bits.

## ◆ YYJSON_RESERVED_MASK

#define YYJSON_RESERVED_MASK ((uint8_t)0xE0) /* 111_____ */

The mask used to extract the reserved bits of a JSON value.

## ◆ YYJSON_STDC_VER

#define YYJSON_STDC_VER 0

C version (STDC)

## ◆ YYJSON_SUBTYPE_BIT

#define YYJSON_SUBTYPE_BIT ((uint8_t)2)

The number of bits used by the subtype.

## ◆ YYJSON_SUBTYPE_FALSE

#define YYJSON_SUBTYPE_FALSE ((uint8_t)(0 << 3)) /* ___00___ */

False subtype: `false` literal.

## ◆ YYJSON_SUBTYPE_MASK

#define YYJSON_SUBTYPE_MASK ((uint8_t)0x18) /* ___11___ */

The mask used to extract the subtype of a JSON value.

## ◆ YYJSON_SUBTYPE_NOESC

#define YYJSON_SUBTYPE_NOESC ((uint8_t)(1 << 3)) /* ___01___ */

String that do not need to be escaped for writing (internal use).

## ◆ YYJSON_SUBTYPE_NONE

#define YYJSON_SUBTYPE_NONE ((uint8_t)(0 << 3)) /* ___00___ */

No subtype.

## ◆ YYJSON_SUBTYPE_REAL

#define YYJSON_SUBTYPE_REAL ((uint8_t)(2 << 3)) /* ___10___ */

Real number subtype: `double`.

## ◆ YYJSON_SUBTYPE_SINT

#define YYJSON_SUBTYPE_SINT ((uint8_t)(1 << 3)) /* ___01___ */

Signed integer subtype: `int64_t`.

## ◆ YYJSON_SUBTYPE_TRUE

#define YYJSON_SUBTYPE_TRUE ((uint8_t)(1 << 3)) /* ___01___ */

True subtype: `true` literal.

## ◆ YYJSON_SUBTYPE_UINT

#define YYJSON_SUBTYPE_UINT ((uint8_t)(0 << 3)) /* ___00___ */

Unsigned integer subtype: `uint64_t`.

## ◆ YYJSON_TAG_BIT

#define YYJSON_TAG_BIT ((uint8_t)8)

The number of bits used by the tag.

## ◆ YYJSON_TAG_MASK

#define YYJSON_TAG_MASK ((uint8_t)0xFF) /* 11111111 */

The mask used to extract the tag of a JSON value.

## ◆ YYJSON_TYPE_ARR

#define YYJSON_TYPE_ARR ((uint8_t)6) /* _____110 */

Array type, no subtype.

## ◆ YYJSON_TYPE_BIT

#define YYJSON_TYPE_BIT ((uint8_t)3)

The number of bits used by the type.

## ◆ YYJSON_TYPE_BOOL

#define YYJSON_TYPE_BOOL ((uint8_t)3) /* _____011 */

Boolean type, subtype: TRUE, FALSE.

## ◆ YYJSON_TYPE_MASK

#define YYJSON_TYPE_MASK ((uint8_t)0x07) /* _____111 */

The mask used to extract the type of a JSON value.

## ◆ YYJSON_TYPE_NONE

#define YYJSON_TYPE_NONE ((uint8_t)0) /* _____000 */

No type, invalid.

## ◆ YYJSON_TYPE_NULL

#define YYJSON_TYPE_NULL ((uint8_t)2) /* _____010 */

Null type: `null` literal, no subtype.

## ◆ YYJSON_TYPE_NUM

#define YYJSON_TYPE_NUM ((uint8_t)4) /* _____100 */

Number type, subtype: UINT, SINT, REAL.

## ◆ YYJSON_TYPE_OBJ

#define YYJSON_TYPE_OBJ ((uint8_t)7) /* _____111 */

Object type, no subtype.

## ◆ YYJSON_TYPE_RAW

#define YYJSON_TYPE_RAW ((uint8_t)1) /* _____001 */

Raw string type, no subtype.

## ◆ YYJSON_TYPE_STR

#define YYJSON_TYPE_STR ((uint8_t)5) /* _____101 */

String type, subtype: NONE, NOESC.

## ◆ YYJSON_U64_TO_F64_NO_IMPL

#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.

## ◆ yyjson_unlikely

#define yyjson_unlikely | ( |  | expr | ) | (expr)

unlikely for compiler

## ◆ YYJSON_VERSION_HEX

#define YYJSON_VERSION_HEX 0x000A00

The version of yyjson in hex: `(major << 16) | (minor << 8) | (patch)`.

## ◆ YYJSON_VERSION_MAJOR

#define YYJSON_VERSION_MAJOR 0

The major version of yyjson.

## ◆ YYJSON_VERSION_MINOR

#define YYJSON_VERSION_MINOR 10

The minor version of yyjson.

## ◆ YYJSON_VERSION_PATCH

#define YYJSON_VERSION_PATCH 0

The patch version of yyjson.

## ◆ YYJSON_VERSION_STRING

#define YYJSON_VERSION_STRING "0.10.0"

The version string of yyjson.

## Typedef Documentation

## ◆ yyjson_patch_code

typedef uint32_t yyjson_patch_code

Result code for JSON patch.

## ◆ yyjson_ptr_code

typedef uint32_t yyjson_ptr_code

JSON Pointer error code.

## ◆ yyjson_read_code

typedef uint32_t yyjson_read_code

Result code for JSON reader.

## ◆ yyjson_read_flag

typedef uint32_t yyjson_read_flag

Run-time options for JSON reader.

## ◆ yyjson_subtype

typedef uint8_t yyjson_subtype

Subtype of a JSON value (2 bit).

## ◆ yyjson_type

typedef uint8_t yyjson_type

Type of a JSON value (3 bit).

## ◆ yyjson_write_code

typedef uint32_t yyjson_write_code

Result code for JSON writer

## ◆ yyjson_write_flag

typedef uint32_t yyjson_write_flag

Run-time options for JSON writer.

## Function Documentation

## ◆ yyjson_alc_dyn_free()

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_alc_dyn_new()

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.

Returns
  A new dynamic allocator, or NULL if memory allocation failed.

Note
  The returned value should be freed with `yyjson_alc_dyn_free()`.

Warning
  This Allocator is not thread-safe.

## ◆ yyjson_alc_pool_init()

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.

Returns
  true 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_alc
  Definition: yyjson.h:618
  yyjson_alc_pool_init
  yyjson_api bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, size_t size)
  yyjson_read_opts
  yyjson_api yyjson_doc * yyjson_read_opts(char *dat, size_t len, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)
  yyjson_doc
  Definition: yyjson.h:4519

Warning
  This Allocator is not thread-safe.

## ◆ yyjson_arr_get()

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.

Warning
  This function takes a linear search time if array is not flat. For example: `[1,{},3]` is flat, `[1,[2],3]` is not flat.

## ◆ yyjson_arr_get_first()

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_arr_get_last()

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.

Warning
  This function takes a linear search time if array is not flat. For example: `[1,{},3]` is flat, `[1,[2],3]` is not flat.

## ◆ yyjson_arr_iter_has_next()

yyjson_api_inline bool yyjson_arr_iter_has_next | ( | yyjson_arr_iter * | iter | ) |

Returns whether the iteration has more elements. If `iter` is NULL, this function will return false.

## ◆ yyjson_arr_iter_init()

yyjson_api_inline bool yyjson_arr_iter_init | ( | yyjson_val * | arr,
|  | yyjson_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.

Returns
  true if the `iter` has been successfully initialized.

Note
  The iterator does not need to be destroyed.

## ◆ yyjson_arr_iter_next()

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_arr_iter_with()

yyjson_api_inline yyjson_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.

Returns
  A new iterator for the array.

Note
  The iterator does not need to be destroyed.

## ◆ yyjson_arr_size()

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_deprecated() [1/10]

yyjson_deprecated | ( | "renamed to unsafe_yyjson_mut_ptr_getx" |  | ) |

Deprecated:
  renamed to `unsafe_yyjson_mut_ptr_getx`

## ◆ yyjson_deprecated() [2/10]

yyjson_deprecated | ( | "renamed to unsafe_yyjson_ptr_getn" |  | ) |

Deprecated:
  renamed to `yyjson_mut_ptr_getn`

## ◆ yyjson_deprecated() [3/10]

yyjson_deprecated | ( | "renamed to yyjson_doc_ptr_get" |  | ) |

Deprecated:
  renamed to `yyjson_doc_ptr_get`

## ◆ yyjson_deprecated() [4/10]

yyjson_deprecated | ( | "renamed to yyjson_doc_ptr_getn" |  | ) |

Deprecated:
  renamed to `yyjson_doc_ptr_getn`

## ◆ yyjson_deprecated() [5/10]

yyjson_deprecated | ( | "renamed to yyjson_mut_doc_ptr_get" |  | ) |

Deprecated:
  renamed to `yyjson_mut_doc_ptr_get`

## ◆ yyjson_deprecated() [6/10]

yyjson_deprecated | ( | "renamed to yyjson_mut_doc_ptr_getn" |  | ) |

Deprecated:
  renamed to `yyjson_mut_doc_ptr_getn`

## ◆ yyjson_deprecated() [7/10]

yyjson_deprecated | ( | "renamed to yyjson_mut_ptr_get" |  | ) |

Deprecated:
  renamed to `yyjson_mut_ptr_get`

## ◆ yyjson_deprecated() [8/10]

yyjson_deprecated | ( | "renamed to yyjson_mut_ptr_getn" |  | ) |

Deprecated:
  renamed to `yyjson_mut_ptr_getn`

## ◆ yyjson_deprecated() [9/10]

yyjson_deprecated | ( | "renamed to yyjson_ptr_get" |  | ) |

Deprecated:
  renamed to `yyjson_ptr_get`

## ◆ yyjson_deprecated() [10/10]

yyjson_deprecated | ( | "renamed to yyjson_ptr_getn" |  | ) |

Deprecated:
  renamed to `yyjson_ptr_getn`

## ◆ yyjson_doc_free()

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_doc_get_read_size()

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_doc_get_root()

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_doc_get_val_count()

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_doc_mut_copy()

yyjson_api yyjson_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.

Note
  `imut_doc` -> `mut_doc`.

## ◆ yyjson_doc_ptr_get()

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).

Returns
  The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_doc_ptr_getn()

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.

Returns
  The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_doc_ptr_getx()

yyjson_api_inline yyjson_val * yyjson_doc_ptr_getx | ( | yyjson_doc * | doc,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_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.

Returns
  The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_equals()

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.

Note
  the result may be inaccurate if object has duplicate keys.

Warning
  This function is recursive and may cause a stack overflow if the object level is too deep.

## ◆ yyjson_equals_str()

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_equals_strn()

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_get_bool()

yyjson_api_inline bool yyjson_get_bool | ( | yyjson_val * | val | ) |

Returns the content if the value is bool. Returns NULL if `val` is NULL or type is not bool.

## ◆ yyjson_get_int()

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_get_len()

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_get_num()

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_get_raw()

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_get_real()

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_get_sint()

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_get_str()

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_get_subtype()

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_get_tag()

yyjson_api_inline uint8_t yyjson_get_tag | ( | yyjson_val * | val | ) |

Returns the JSON value's tag. Returns 0 if `val` is NULL.

## ◆ yyjson_get_type()

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_get_type_desc()

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_get_uint()

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_is_arr()

yyjson_api_inline bool yyjson_is_arr | ( | yyjson_val * | val | ) |

Returns whether the JSON value is array. Returns false if `val` is NULL.

## ◆ yyjson_is_bool()

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_is_ctn()

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_is_false()

yyjson_api_inline bool yyjson_is_false | ( | yyjson_val * | val | ) |

Returns whether the JSON value is `false`. Returns false if `val` is NULL.

## ◆ yyjson_is_int()

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_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_is_num()

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_is_obj()

yyjson_api_inline bool yyjson_is_obj | ( | yyjson_val * | val | ) |

Returns whether the JSON value is object. Returns false if `val` is NULL.

## ◆ yyjson_is_raw()

yyjson_api_inline bool yyjson_is_raw | ( | yyjson_val * | val | ) |

Returns whether the JSON value is raw. Returns false if `val` is NULL.

## ◆ yyjson_is_real()

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_is_sint()

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_is_str()

yyjson_api_inline bool yyjson_is_str | ( | yyjson_val * | val | ) |

Returns whether the JSON value is string. Returns false if `val` is NULL.

## ◆ yyjson_is_true()

yyjson_api_inline bool yyjson_is_true | ( | yyjson_val * | val | ) |

Returns whether the JSON value is `true`. Returns false if `val` is NULL.

## ◆ yyjson_is_uint()

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_locate_pos()

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.

Returns
  true on success, false if `str` is NULL or `pos` is out of bounds.

Note
  Line/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_merge_patch()

yyjson_api yyjson_mut_val * yyjson_merge_patch | ( | yyjson_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.

Warning
  This function is recursive and may cause a stack overflow if the object level is too deep.

## ◆ yyjson_mut_arr()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr | ( | yyjson_mut_doc * | doc | ) |

Creates and returns an empty mutable array.

Parameters

  doc | A mutable document, used for memory allocation only.

Returns
  The new array. NULL if input is NULL or memory allocation failed.

## ◆ yyjson_mut_arr_add_arr()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_add_arr | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  The new array, or NULL on error.

## ◆ yyjson_mut_arr_add_bool()

yyjson_api_inline bool yyjson_mut_arr_add_bool | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_add_false()

yyjson_api_inline bool yyjson_mut_arr_add_false | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_add_int()

yyjson_api_inline bool yyjson_mut_arr_add_int | ( | yyjson_mut_doc * | doc,
|  | yyjson_mut_val * | arr,
|  | int64_t | num
| ) |  |

Adds a 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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_add_null()

yyjson_api_inline bool yyjson_mut_arr_add_null | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_add_obj()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_add_obj | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  The new object, or NULL on error.

## ◆ yyjson_mut_arr_add_real()

yyjson_api_inline bool yyjson_mut_arr_add_real | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_add_sint()

yyjson_api_inline bool yyjson_mut_arr_add_sint | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_add_str()

yyjson_api_inline bool yyjson_mut_arr_add_str | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  Whether successful.

Warning
  The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_arr_add_strcpy()

yyjson_api_inline bool yyjson_mut_arr_add_strcpy | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_add_strn()

yyjson_api_inline bool yyjson_mut_arr_add_strn | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  Whether successful.

Warning
  The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_arr_add_strncpy()

yyjson_api_inline bool yyjson_mut_arr_add_strncpy | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_add_true()

yyjson_api_inline bool yyjson_mut_arr_add_true | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_add_uint()

yyjson_api_inline bool yyjson_mut_arr_add_uint | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_add_val()

yyjson_api_inline bool yyjson_mut_arr_add_val | ( | yyjson_mut_val * | arr,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_append()

yyjson_api_inline bool yyjson_mut_arr_append | ( | yyjson_mut_val * | arr,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_clear()

yyjson_api_inline bool yyjson_mut_arr_clear | ( | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_get()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_get | ( | yyjson_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.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_arr_get_first()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_get_first | ( | yyjson_mut_val * | arr | ) |

Returns the first element of this array. Returns NULL if `arr` is NULL/empty or type is not array.

## ◆ yyjson_mut_arr_get_last()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_get_last | ( | yyjson_mut_val * | arr | ) |

Returns the last element of this array. Returns NULL if `arr` is NULL/empty or type is not array.

## ◆ yyjson_mut_arr_insert()

yyjson_api_inline bool yyjson_mut_arr_insert | ( | yyjson_mut_val * | arr,
|  | yyjson_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.

Returns
  Whether successful.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_arr_iter_has_next()

yyjson_api_inline bool yyjson_mut_arr_iter_has_next | ( | yyjson_mut_arr_iter * | iter | ) |

Returns whether the iteration has more elements. If `iter` is NULL, this function will return false.

## ◆ yyjson_mut_arr_iter_init()

yyjson_api_inline bool yyjson_mut_arr_iter_init | ( | yyjson_mut_val * | arr,
|  | yyjson_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.

Returns
  true if the `iter` has been successfully initialized.

Note
  The iterator does not need to be destroyed.

## ◆ yyjson_mut_arr_iter_next()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_iter_next | ( | yyjson_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_mut_arr_iter_remove()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_iter_remove | ( | yyjson_mut_arr_iter * | iter | ) |

Removes and returns current element in the iteration. If `iter` is NULL, this function will return NULL.

## ◆ yyjson_mut_arr_iter_with()

yyjson_api_inline yyjson_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.

Returns
  A new iterator for the array.

Note
  The iterator does not need to be destroyed.

## ◆ yyjson_mut_arr_prepend()

yyjson_api_inline bool yyjson_mut_arr_prepend | ( | yyjson_mut_val * | arr,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_arr_remove()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_remove | ( | yyjson_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.

Returns
  Old value, or NULL on error.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_arr_remove_first()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_remove_first | ( | yyjson_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.

Returns
  The first value, or NULL on error.

## ◆ yyjson_mut_arr_remove_last()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_remove_last | ( | yyjson_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.

Returns
  The last value, or NULL on error.

## ◆ yyjson_mut_arr_remove_range()

yyjson_api_inline bool yyjson_mut_arr_remove_range | ( | yyjson_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).

Returns
  Whether successful.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_arr_replace()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_replace | ( | yyjson_mut_val * | arr,
|  | size_t | idx,
|  | yyjson_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.

Returns
  Old value, or NULL on error.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_arr_rotate()

yyjson_api_inline bool yyjson_mut_arr_rotate | ( | yyjson_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.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_arr_size()

yyjson_api_inline size_t yyjson_mut_arr_size | ( | yyjson_mut_val * | arr | ) |

Returns the number of elements in this array. Returns 0 if `arr` is NULL or type is not array.

## ◆ yyjson_mut_arr_with_bool()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_bool | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const bool vals[3] = { true, false, true };
  yyjson_mut_val *arr = yyjson_mut_arr_with_bool(doc, vals, 3);
  yyjson_mut_arr_with_bool
  yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_bool(yyjson_mut_doc *doc, const bool *vals, size_t count)
  Definition: yyjson.h:5944

## ◆ yyjson_mut_arr_with_double()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_double | ( | yyjson_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.

Returns
  The 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 *arr = yyjson_mut_arr_with_double(doc, vals, 3);
  yyjson_mut_arr_with_double
  yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_double(yyjson_mut_doc *doc, const double *vals, size_t count)
  Definition: yyjson.h:6039

## ◆ yyjson_mut_arr_with_float()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_float | ( | yyjson_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.

Returns
  The 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 *arr = yyjson_mut_arr_with_float(doc, vals, 3);
  yyjson_mut_arr_with_float
  yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_float(yyjson_mut_doc *doc, const float *vals, size_t count)
  Definition: yyjson.h:6031

## ◆ yyjson_mut_arr_with_real()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_real | ( | yyjson_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.

Returns
  The 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 *arr = yyjson_mut_arr_with_real(doc, vals, 3);
  yyjson_mut_arr_with_real
  yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_real(yyjson_mut_doc *doc, const double *vals, size_t count)
  Definition: yyjson.h:5962

## ◆ yyjson_mut_arr_with_sint()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const int64_t vals[3] = { -1, 0, 1 };
  yyjson_mut_val *arr = yyjson_mut_arr_with_sint64(doc, vals, 3);
  yyjson_mut_arr_with_sint64
  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:5991

## ◆ yyjson_mut_arr_with_sint16()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint16 | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const int16_t vals[3] = { -1, 0, 1 };
  yyjson_mut_val *arr = yyjson_mut_arr_with_sint16(doc, vals, 3);
  yyjson_mut_arr_with_sint16
  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:5975

## ◆ yyjson_mut_arr_with_sint32()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint32 | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const int32_t vals[3] = { -1, 0, 1 };
  yyjson_mut_val *arr = yyjson_mut_arr_with_sint32(doc, vals, 3);
  yyjson_mut_arr_with_sint32
  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:5983

## ◆ yyjson_mut_arr_with_sint64()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint64 | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const int64_t vals[3] = { -1, 0, 1 };
  yyjson_mut_val *arr = yyjson_mut_arr_with_sint64(doc, vals, 3);

## ◆ yyjson_mut_arr_with_sint8()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_sint8 | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const int8_t vals[3] = { -1, 0, 1 };
  yyjson_mut_val *arr = yyjson_mut_arr_with_sint8(doc, vals, 3);
  yyjson_mut_arr_with_sint8
  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:5967

## ◆ yyjson_mut_arr_with_str()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_str | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Warning
  The 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 *arr = yyjson_mut_arr_with_str(doc, vals, 3);
  yyjson_mut_arr_with_str
  yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_str(yyjson_mut_doc *doc, const char **vals, size_t count)
  Definition: yyjson.h:6047

## ◆ yyjson_mut_arr_with_strcpy()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_strcpy | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const char *vals[3] = { "a", "b", "c" };
  yyjson_mut_val *arr = yyjson_mut_arr_with_strcpy(doc, vals, 3);
  yyjson_mut_arr_with_strcpy
  yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_strcpy(yyjson_mut_doc *doc, const char **vals, size_t count)
  Definition: yyjson.h:6067

## ◆ yyjson_mut_arr_with_strn()

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
| ) |  |

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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Warning
  The 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 *arr = yyjson_mut_arr_with_strn(doc, vals, lens, 3);
  yyjson_mut_arr_with_strn
  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:6057

## ◆ yyjson_mut_arr_with_strncpy()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_strncpy | ( | yyjson_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.

Returns
  The 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 *arr = yyjson_mut_arr_with_strn(doc, vals, lens, 3);

## ◆ yyjson_mut_arr_with_uint()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const uint64_t vals[3] = { 0, 1, 0 };
  yyjson_mut_val *arr = yyjson_mut_arr_with_uint(doc, vals, 3);
  yyjson_mut_arr_with_uint
  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:5957

## ◆ yyjson_mut_arr_with_uint16()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint16 | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const uint16_t vals[3] = { 0, 1, 0 };
  yyjson_mut_val *arr = yyjson_mut_arr_with_uint16(doc, vals, 3);
  yyjson_mut_arr_with_uint16
  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:6007

## ◆ yyjson_mut_arr_with_uint32()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint32 | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const uint32_t vals[3] = { 0, 1, 0 };
  yyjson_mut_val *arr = yyjson_mut_arr_with_uint32(doc, vals, 3);
  yyjson_mut_arr_with_uint32
  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:6015

## ◆ yyjson_mut_arr_with_uint64()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint64 | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const uint64_t vals[3] = { 0, 1, 0 };
  yyjson_mut_val *arr = yyjson_mut_arr_with_uint64(doc, vals, 3);
  yyjson_mut_arr_with_uint64
  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:6023

## ◆ yyjson_mut_arr_with_uint8()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_uint8 | ( | yyjson_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.

Returns
  The new array. NULL if input is invalid or memory allocation failed.

Example
  const uint8_t vals[3] = { 0, 1, 0 };
  yyjson_mut_val *arr = yyjson_mut_arr_with_uint8(doc, vals, 3);
  yyjson_mut_arr_with_uint8
  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:5999

## ◆ yyjson_mut_bool()

yyjson_api_inline yyjson_mut_val * yyjson_mut_bool | ( | yyjson_mut_doc * | doc,
|  | bool | val
| ) |  |

Creates and returns a bool value, returns NULL on error.

## ◆ yyjson_mut_doc_free()

yyjson_api void yyjson_mut_doc_free | ( | yyjson_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_mut_doc_get_root()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_get_root | ( | yyjson_mut_doc * | doc | ) |

Returns the root value of this JSON document. Returns NULL if `doc` is NULL.

## ◆ yyjson_mut_doc_imut_copy()

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()`.

Note
  `mut_doc` -> `imut_doc`.

Warning
  This function is recursive and may cause a stack overflow if the object level is too deep.

## ◆ yyjson_mut_doc_mut_copy()

yyjson_api yyjson_mut_doc * yyjson_mut_doc_mut_copy | ( | yyjson_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.

Note
  `mut_doc` -> `mut_doc`.

## ◆ yyjson_mut_doc_new()

yyjson_api yyjson_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_mut_doc_ptr_add()

yyjson_api_inline bool yyjson_mut_doc_ptr_add | ( | yyjson_mut_doc * | doc,
|  | const char * | ptr,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is added, false otherwise.

Note
  The parent nodes will be created if they do not exist.

## ◆ yyjson_mut_doc_ptr_addn()

yyjson_api_inline bool yyjson_mut_doc_ptr_addn | ( | yyjson_mut_doc * | doc,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is added, false otherwise.

Note
  The parent nodes will be created if they do not exist.

## ◆ yyjson_mut_doc_ptr_addx()

yyjson_api_inline bool yyjson_mut_doc_ptr_addx | ( | yyjson_mut_doc * | doc,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_mut_val * | new_val,
|  | bool | create_parent,
|  | yyjson_ptr_ctx * | ctx,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is added, false otherwise.

## ◆ yyjson_mut_doc_ptr_get()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_get | ( | yyjson_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).

Returns
  The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_mut_doc_ptr_getn()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_getn | ( | yyjson_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.

Returns
  The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_mut_doc_ptr_getx()

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
| ) |  |

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.

Returns
  The value referenced by the JSON pointer. NULL if `doc` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_mut_doc_ptr_remove()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_remove | ( | yyjson_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).

Returns
  The removed value, or NULL on error.

## ◆ yyjson_mut_doc_ptr_removen()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_removen | ( | yyjson_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.

Returns
  The removed value, or NULL on error.

## ◆ yyjson_mut_doc_ptr_removex()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_removex | ( | yyjson_mut_doc * | doc,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_ptr_ctx * | ctx,
|  | yyjson_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.

Returns
  The removed value, or NULL on error.

## ◆ yyjson_mut_doc_ptr_replace()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_replace | ( | yyjson_mut_doc * | doc,
|  | const char * | ptr,
|  | yyjson_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.

Returns
  The old value that was replaced, or NULL if not found.

## ◆ yyjson_mut_doc_ptr_replacen()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_replacen | ( | yyjson_mut_doc * | doc,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_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.

Returns
  The old value that was replaced, or NULL if not found.

## ◆ yyjson_mut_doc_ptr_replacex()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_replacex | ( | yyjson_mut_doc * | doc,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_mut_val * | new_val,
|  | yyjson_ptr_ctx * | ctx,
|  | yyjson_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.

Returns
  The old value that was replaced, or NULL if not found.

## ◆ yyjson_mut_doc_ptr_set()

yyjson_api_inline bool yyjson_mut_doc_ptr_set | ( | yyjson_mut_doc * | doc,
|  | const char * | ptr,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is set, false otherwise.

Note
  The 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_mut_doc_ptr_setn()

yyjson_api_inline bool yyjson_mut_doc_ptr_setn | ( | yyjson_mut_doc * | doc,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is set, false otherwise.

Note
  The 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_mut_doc_ptr_setx()

yyjson_api_inline bool yyjson_mut_doc_ptr_setx | ( | yyjson_mut_doc * | doc,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_mut_val * | new_val,
|  | bool | create_parent,
|  | yyjson_ptr_ctx * | ctx,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is set, false otherwise.

Note
  If the target value already exists, it will be replaced by the new value.

## ◆ yyjson_mut_doc_set_root()

yyjson_api_inline void yyjson_mut_doc_set_root | ( | yyjson_mut_doc * | doc,
|  | yyjson_mut_val * | root
| ) |  |

Sets the root value of this JSON document. Pass NULL to clear root value of the document.

## ◆ yyjson_mut_doc_set_str_pool_size()

yyjson_api bool yyjson_mut_doc_set_str_pool_size | ( | yyjson_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).

Returns
  true if successful, false if size is 0 or overflow.

## ◆ yyjson_mut_doc_set_val_pool_size()

yyjson_api bool yyjson_mut_doc_set_val_pool_size | ( | yyjson_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`).

Returns
  true if successful, false if size is 0 or overflow.

## ◆ yyjson_mut_equals()

yyjson_api_inline bool yyjson_mut_equals | ( | yyjson_mut_val * | lhs,
|  | yyjson_mut_val * | rhs
| ) |  |

Returns whether two JSON values are equal (deep compare). Returns false if input is NULL.

Note
  the result may be inaccurate if object has duplicate keys.

Warning
  This function is recursive and may cause a stack overflow if the object level is too deep.

## ◆ yyjson_mut_equals_str()

yyjson_api_inline bool yyjson_mut_equals_str | ( | yyjson_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_mut_equals_strn()

yyjson_api_inline bool yyjson_mut_equals_strn | ( | yyjson_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_mut_false()

yyjson_api_inline yyjson_mut_val * yyjson_mut_false | ( | yyjson_mut_doc * | doc | ) |

Creates and returns a false value, returns NULL on error.

## ◆ yyjson_mut_get_bool()

yyjson_api_inline bool yyjson_mut_get_bool | ( | yyjson_mut_val * | val | ) |

Returns the content if the value is bool. Returns NULL if `val` is NULL or type is not bool.

## ◆ yyjson_mut_get_int()

yyjson_api_inline int yyjson_mut_get_int | ( | yyjson_mut_val * | val | ) |

Returns the content and cast to int. Returns 0 if `val` is NULL or type is not integer(sint/uint).

## ◆ yyjson_mut_get_len()

yyjson_api_inline size_t yyjson_mut_get_len | ( | yyjson_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_mut_get_num()

yyjson_api_inline double yyjson_mut_get_num | ( | yyjson_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_mut_get_raw()

yyjson_api_inline const char * yyjson_mut_get_raw | ( | yyjson_mut_val * | val | ) |

Returns the content if the value is raw. Returns NULL if `val` is NULL or type is not raw.

## ◆ yyjson_mut_get_real()

yyjson_api_inline double yyjson_mut_get_real | ( | yyjson_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_mut_get_sint()

yyjson_api_inline int64_t yyjson_mut_get_sint | ( | yyjson_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_mut_get_str()

yyjson_api_inline const char * yyjson_mut_get_str | ( | yyjson_mut_val * | val | ) |

Returns the content if the value is string. Returns NULL if `val` is NULL or type is not string.

## ◆ yyjson_mut_get_subtype()

yyjson_api_inline yyjson_subtype yyjson_mut_get_subtype | ( | yyjson_mut_val * | val | ) |

Returns the JSON value's subtype. Returns `YYJSON_SUBTYPE_NONE` if `val` is NULL.

## ◆ yyjson_mut_get_tag()

yyjson_api_inline uint8_t yyjson_mut_get_tag | ( | yyjson_mut_val * | val | ) |

Returns the JSON value's tag. Returns 0 if `val` is NULL.

## ◆ yyjson_mut_get_type()

yyjson_api_inline yyjson_type yyjson_mut_get_type | ( | yyjson_mut_val * | val | ) |

Returns the JSON value's type. Returns `YYJSON_TYPE_NONE` if `val` is NULL.

## ◆ yyjson_mut_get_type_desc()

yyjson_api_inline const char * yyjson_mut_get_type_desc | ( | yyjson_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_mut_get_uint()

yyjson_api_inline uint64_t yyjson_mut_get_uint | ( | yyjson_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_mut_int()

yyjson_api_inline yyjson_mut_val * yyjson_mut_int | ( | yyjson_mut_doc * | doc,
|  | int64_t | num
| ) |  |

Creates and returns a signed integer value, returns NULL on error.

## ◆ yyjson_mut_is_arr()

yyjson_api_inline bool yyjson_mut_is_arr | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is array. Returns false if `val` is NULL.

## ◆ yyjson_mut_is_bool()

yyjson_api_inline bool yyjson_mut_is_bool | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is bool (true/false). Returns false if `val` is NULL.

## ◆ yyjson_mut_is_ctn()

yyjson_api_inline bool yyjson_mut_is_ctn | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is container (array/object). Returns false if `val` is NULL.

## ◆ yyjson_mut_is_false()

yyjson_api_inline bool yyjson_mut_is_false | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is `false`. Returns false if `val` is NULL.

## ◆ yyjson_mut_is_int()

yyjson_api_inline bool yyjson_mut_is_int | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is integer (uint64_t/int64_t). Returns false if `val` is NULL.

## ◆ yyjson_mut_is_null()

yyjson_api_inline bool yyjson_mut_is_null | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is `null`. Returns false if `val` is NULL.

## ◆ yyjson_mut_is_num()

yyjson_api_inline bool yyjson_mut_is_num | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is number (uint/sint/real). Returns false if `val` is NULL.

## ◆ yyjson_mut_is_obj()

yyjson_api_inline bool yyjson_mut_is_obj | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is object. Returns false if `val` is NULL.

## ◆ yyjson_mut_is_raw()

yyjson_api_inline bool yyjson_mut_is_raw | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is raw. Returns false if `val` is NULL.

## ◆ yyjson_mut_is_real()

yyjson_api_inline bool yyjson_mut_is_real | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is real number (double). Returns false if `val` is NULL.

## ◆ yyjson_mut_is_sint()

yyjson_api_inline bool yyjson_mut_is_sint | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is signed integer (int64_t). Returns false if `val` is NULL.

## ◆ yyjson_mut_is_str()

yyjson_api_inline bool yyjson_mut_is_str | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is string. Returns false if `val` is NULL.

## ◆ yyjson_mut_is_true()

yyjson_api_inline bool yyjson_mut_is_true | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is `true`. Returns false if `val` is NULL.

## ◆ yyjson_mut_is_uint()

yyjson_api_inline bool yyjson_mut_is_uint | ( | yyjson_mut_val * | val | ) |

Returns whether the JSON value is unsigned integer (uint64_t). Returns false if `val` is NULL.

## ◆ yyjson_mut_merge_patch()

yyjson_api yyjson_mut_val * yyjson_mut_merge_patch | ( | yyjson_mut_doc * | doc,
|  | yyjson_mut_val * | orig,
|  | yyjson_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.

Warning
  This function is recursive and may cause a stack overflow if the object level is too deep.

## ◆ yyjson_mut_null()

yyjson_api_inline yyjson_mut_val * yyjson_mut_null | ( | yyjson_mut_doc * | doc | ) |

Creates and returns a null value, returns NULL on error.

## ◆ yyjson_mut_obj()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj | ( | yyjson_mut_doc * | doc | ) |

Creates and returns a mutable object, returns NULL on error.

## ◆ yyjson_mut_obj_add()

yyjson_api_inline bool yyjson_mut_obj_add | ( | yyjson_mut_val * | obj,
|  | yyjson_mut_val * | key,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_obj_add_arr()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_add_arr | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep these strings unmodified for the lifetime of this JSON document.

Returns
  The new array, or NULL on error.

## ◆ yyjson_mut_obj_add_bool()

yyjson_api_inline bool yyjson_mut_obj_add_bool | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_false()

yyjson_api_inline bool yyjson_mut_obj_add_false | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_int()

yyjson_api_inline bool yyjson_mut_obj_add_int | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_null()

yyjson_api_inline bool yyjson_mut_obj_add_null | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_obj()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_add_obj | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep these strings unmodified for the lifetime of this JSON document.

Returns
  The new object, or NULL on error.

## ◆ yyjson_mut_obj_add_real()

yyjson_api_inline bool yyjson_mut_obj_add_real | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_sint()

yyjson_api_inline bool yyjson_mut_obj_add_sint | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_str()

yyjson_api_inline bool yyjson_mut_obj_add_str | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key/value strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_strcpy()

yyjson_api_inline bool yyjson_mut_obj_add_strcpy | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_strn()

yyjson_api_inline bool yyjson_mut_obj_add_strn | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key/value strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_strncpy()

yyjson_api_inline bool yyjson_mut_obj_add_strncpy | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_true()

yyjson_api_inline bool yyjson_mut_obj_add_true | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_uint()

yyjson_api_inline bool yyjson_mut_obj_add_uint | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_add_val()

yyjson_api_inline bool yyjson_mut_obj_add_val | ( | yyjson_mut_doc * | doc,
|  | yyjson_mut_val * | obj,
|  | const char * | key,
|  | yyjson_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.

Warning
  The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_obj_clear()

yyjson_api_inline bool yyjson_mut_obj_clear | ( | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_obj_get()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_get | ( | yyjson_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.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_obj_getn()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_getn | ( | yyjson_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.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_obj_insert()

yyjson_api_inline bool yyjson_mut_obj_insert | ( | yyjson_mut_val * | obj,
|  | yyjson_mut_val * | key,
|  | yyjson_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.

Returns
  Whether successful.

## ◆ yyjson_mut_obj_iter_get()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_get | ( | yyjson_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.

Returns
  The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid.

Warning
  This function takes a linear search time if the key is not nearby.

## ◆ yyjson_mut_obj_iter_get_val()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_get_val | ( | yyjson_mut_val * | key | ) |

Returns the value for key inside the iteration. If `iter` is NULL, this function will return NULL.

## ◆ yyjson_mut_obj_iter_getn()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_getn | ( | yyjson_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.

Returns
  The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid.

Warning
  This function takes a linear search time if the key is not nearby.

## ◆ yyjson_mut_obj_iter_has_next()

yyjson_api_inline bool yyjson_mut_obj_iter_has_next | ( | yyjson_mut_obj_iter * | iter | ) |

Returns whether the iteration has more elements. If `iter` is NULL, this function will return false.

## ◆ yyjson_mut_obj_iter_init()

yyjson_api_inline bool yyjson_mut_obj_iter_init | ( | yyjson_mut_val * | obj,
|  | yyjson_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.

Returns
  true if the `iter` has been successfully initialized.

Note
  The iterator does not need to be destroyed.

## ◆ yyjson_mut_obj_iter_next()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_next | ( | yyjson_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_mut_obj_iter_remove()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_remove | ( | yyjson_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_mut_obj_iter_with()

yyjson_api_inline yyjson_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.

Returns
  A new iterator for the object.

Note
  The iterator does not need to be destroyed.

## ◆ yyjson_mut_obj_put()

yyjson_api_inline bool yyjson_mut_obj_put | ( | yyjson_mut_val * | obj,
|  | yyjson_mut_val * | key,
|  | yyjson_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()`.

Returns
  Whether successful.

## ◆ yyjson_mut_obj_remove()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_remove | ( | yyjson_mut_val * | obj,
|  | yyjson_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.

Returns
  The first matched value, or NULL if no matched value.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_obj_remove_key()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_remove_key | ( | yyjson_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.

Returns
  The first matched value, or NULL if no matched value.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_obj_remove_keyn()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_remove_keyn | ( | yyjson_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.

Returns
  The first matched value, or NULL if no matched value.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_obj_remove_str()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_remove_str | ( | yyjson_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.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_obj_remove_strn()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_remove_strn | ( | yyjson_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.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_obj_rename_key()

yyjson_api_inline bool yyjson_mut_obj_rename_key | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  This function takes a linear search time. If `new_key` already exists, it will cause duplicate keys.

## ◆ yyjson_mut_obj_rename_keyn()

yyjson_api_inline bool yyjson_mut_obj_rename_keyn | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Warning
  This function takes a linear search time. If `new_key` already exists, it will cause duplicate keys.

## ◆ yyjson_mut_obj_replace()

yyjson_api_inline bool yyjson_mut_obj_replace | ( | yyjson_mut_val * | obj,
|  | yyjson_mut_val * | key,
|  | yyjson_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.

Returns
  Whether successful.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_obj_rotate()

yyjson_api_inline bool yyjson_mut_obj_rotate | ( | yyjson_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.

Returns
  Whether successful.

Warning
  This function takes a linear search time.

## ◆ yyjson_mut_obj_size()

yyjson_api_inline size_t yyjson_mut_obj_size | ( | yyjson_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_mut_obj_with_kv()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_with_kv | ( | yyjson_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.

Warning
  The 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 *obj = yyjson_mut_obj_with_kv(doc, kv_pairs, 2);
  yyjson_mut_obj_with_kv
  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:6621

## ◆ yyjson_mut_obj_with_str()

yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_with_str | ( | yyjson_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.

Warning
  The 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 *obj = yyjson_mut_obj_with_str(doc, keys, vals, 2);
  yyjson_mut_obj_with_str
  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:6590

## ◆ yyjson_mut_patch()

yyjson_api yyjson_mut_val * yyjson_mut_patch | ( | yyjson_mut_doc * | doc,
|  | yyjson_mut_val * | orig,
|  | yyjson_mut_val * | patch,
|  | yyjson_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_mut_ptr_add()

yyjson_api_inline bool yyjson_mut_ptr_add | ( | yyjson_mut_val * | val,
|  | const char * | ptr,
|  | yyjson_mut_val * | new_val,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is added, false otherwise.

Note
  The parent nodes will be created if they do not exist.

## ◆ yyjson_mut_ptr_addn()

yyjson_api_inline bool yyjson_mut_ptr_addn | ( | yyjson_mut_val * | val,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_mut_val * | new_val,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is added, false otherwise.

Note
  The parent nodes will be created if they do not exist.

## ◆ yyjson_mut_ptr_addx()

yyjson_api_inline bool yyjson_mut_ptr_addx | ( | yyjson_mut_val * | val,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_mut_val * | new_val,
|  | yyjson_mut_doc * | doc,
|  | bool | create_parent,
|  | yyjson_ptr_ctx * | ctx,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is added, false otherwise.

## ◆ yyjson_mut_ptr_get()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_get | ( | yyjson_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).

Returns
  The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_mut_ptr_getn()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_getn | ( | yyjson_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.

Returns
  The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_mut_ptr_getx()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_getx | ( | yyjson_mut_val * | val,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_ptr_ctx * | ctx,
|  | yyjson_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.

Returns
  The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_mut_ptr_remove()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_remove | ( | yyjson_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).

Returns
  The removed value, or NULL on error.

## ◆ yyjson_mut_ptr_removen()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_removen | ( | yyjson_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.

Returns
  The removed value, or NULL on error.

## ◆ yyjson_mut_ptr_removex()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_removex | ( | yyjson_mut_val * | val,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_ptr_ctx * | ctx,
|  | yyjson_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.

Returns
  The removed value, or NULL on error.

## ◆ yyjson_mut_ptr_replace()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_replace | ( | yyjson_mut_val * | val,
|  | const char * | ptr,
|  | yyjson_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.

Returns
  The old value that was replaced, or NULL if not found.

## ◆ yyjson_mut_ptr_replacen()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_replacen | ( | yyjson_mut_val * | val,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_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.

Returns
  The old value that was replaced, or NULL if not found.

## ◆ yyjson_mut_ptr_replacex()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_replacex | ( | yyjson_mut_val * | val,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_mut_val * | new_val,
|  | yyjson_ptr_ctx * | ctx,
|  | yyjson_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.

Returns
  The old value that was replaced, or NULL if not found.

## ◆ yyjson_mut_ptr_set()

yyjson_api_inline bool yyjson_mut_ptr_set | ( | yyjson_mut_val * | val,
|  | const char * | ptr,
|  | yyjson_mut_val * | new_val,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is set, false otherwise.

Note
  The 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_mut_ptr_setn()

yyjson_api_inline bool yyjson_mut_ptr_setn | ( | yyjson_mut_val * | val,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_mut_val * | new_val,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is set, false otherwise.

Note
  The 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_mut_ptr_setx()

yyjson_api_inline bool yyjson_mut_ptr_setx | ( | yyjson_mut_val * | val,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_mut_val * | new_val,
|  | yyjson_mut_doc * | doc,
|  | bool | create_parent,
|  | yyjson_ptr_ctx * | ctx,
|  | yyjson_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.

Returns
  true if JSON pointer is valid and new value is set, false otherwise.

Note
  If the target value already exists, it will be replaced by the new value.

## ◆ yyjson_mut_raw()

yyjson_api_inline yyjson_mut_val * yyjson_mut_raw | ( | yyjson_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.

Warning
  The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_rawcpy()

yyjson_api_inline yyjson_mut_val * yyjson_mut_rawcpy | ( | yyjson_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_mut_rawn()

yyjson_api_inline yyjson_mut_val * yyjson_mut_rawn | ( | yyjson_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.

Warning
  The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_rawncpy()

yyjson_api_inline yyjson_mut_val * yyjson_mut_rawncpy | ( | yyjson_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_mut_read_number()

yyjson_api_inline const char * yyjson_mut_read_number | ( | const char * | dat,
|  | yyjson_mut_val * | val,
|  | yyjson_read_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_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.

Returns
  If successful, a pointer to the character after the last character used in the conversion, NULL if an error occurs.

## ◆ yyjson_mut_real()

yyjson_api_inline yyjson_mut_val * yyjson_mut_real | ( | yyjson_mut_doc * | doc,
|  | double | num
| ) |  |

Creates and returns an real number value, returns NULL on error.

## ◆ yyjson_mut_set_arr()

yyjson_api_inline bool yyjson_mut_set_arr | ( | yyjson_mut_val * | val | ) |

Set the value to array. Returns false if input is NULL.

Warning
  This function should not be used on an existing object or array.

## ◆ yyjson_mut_set_bool()

yyjson_api_inline bool yyjson_mut_set_bool | ( | yyjson_mut_val * | val,
|  | bool | num
| ) |  |

Set the value to bool. Returns false if input is NULL.

Warning
  This function should not be used on an existing object or array.

## ◆ yyjson_mut_set_int()

yyjson_api_inline bool yyjson_mut_set_int | ( | yyjson_mut_val * | val,
|  | int | num
| ) |  |

Set the value to int. Returns false if input is NULL.

Warning
  This function should not be used on an existing object or array.

## ◆ yyjson_mut_set_null()

yyjson_api_inline bool yyjson_mut_set_null | ( | yyjson_mut_val * | val | ) |

Set the value to null. Returns false if input is NULL.

Warning
  This function should not be used on an existing object or array.

## ◆ yyjson_mut_set_obj()

yyjson_api_inline bool yyjson_mut_set_obj | ( | yyjson_mut_val * | val | ) |

Set the value to array. Returns false if input is NULL.

Warning
  This function should not be used on an existing object or array.

## ◆ yyjson_mut_set_raw()

yyjson_api_inline bool yyjson_mut_set_raw | ( | yyjson_mut_val * | val,
|  | const char * | raw,
|  | size_t | len
| ) |  |

Set the value to raw. Returns false if input is NULL.

Warning
  This function should not be used on an existing object or array.

## ◆ yyjson_mut_set_real()

yyjson_api_inline bool yyjson_mut_set_real | ( | yyjson_mut_val * | val,
|  | double | num
| ) |  |

Set the value to real. Returns false if input is NULL.

Warning
  This function should not be used on an existing object or array.

## ◆ yyjson_mut_set_sint()

yyjson_api_inline bool yyjson_mut_set_sint | ( | yyjson_mut_val * | val,
|  | int64_t | num
| ) |  |

Set the value to sint. Returns false if input is NULL.

Warning
  This function should not be used on an existing object or array.

## ◆ yyjson_mut_set_str()

yyjson_api_inline bool yyjson_mut_set_str | ( | yyjson_mut_val * | val,
|  | const char * | str
| ) |  |

Set the value to string (null-terminated). Returns false if input is NULL.

Warning
  This function should not be used on an existing object or array.

## ◆ yyjson_mut_set_strn()

yyjson_api_inline bool yyjson_mut_set_strn | ( | yyjson_mut_val * | val,
|  | const char * | str,
|  | size_t | len
| ) |  |

Set the value to string (with length). Returns false if input is NULL.

Warning
  This function should not be used on an existing object or array.

## ◆ yyjson_mut_set_uint()

yyjson_api_inline bool yyjson_mut_set_uint | ( | yyjson_mut_val * | val,
|  | uint64_t | num
| ) |  |

Set the value to uint. Returns false if input is NULL.

Warning
  This function should not be used on an existing object or array.

## ◆ yyjson_mut_sint()

yyjson_api_inline yyjson_mut_val * yyjson_mut_sint | ( | yyjson_mut_doc * | doc,
|  | int64_t | num
| ) |  |

Creates and returns a signed integer value, returns NULL on error.

## ◆ yyjson_mut_str()

yyjson_api_inline yyjson_mut_val * yyjson_mut_str | ( | yyjson_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.

Warning
  The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_strcpy()

yyjson_api_inline yyjson_mut_val * yyjson_mut_strcpy | ( | yyjson_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_mut_strn()

yyjson_api_inline yyjson_mut_val * yyjson_mut_strn | ( | yyjson_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.

Warning
  The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.

## ◆ yyjson_mut_strncpy()

yyjson_api_inline yyjson_mut_val * yyjson_mut_strncpy | ( | yyjson_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_mut_true()

yyjson_api_inline yyjson_mut_val * yyjson_mut_true | ( | yyjson_mut_doc * | doc | ) |

Creates and returns a true value, returns NULL on error.

## ◆ yyjson_mut_uint()

yyjson_api_inline yyjson_mut_val * yyjson_mut_uint | ( | yyjson_mut_doc * | doc,
|  | uint64_t | num
| ) |  |

Creates and returns an unsigned integer value, returns NULL on error.

## ◆ yyjson_mut_val_imut_copy()

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()`.

Note
  `mut_val` -> `imut_doc`.

Warning
  This function is recursive and may cause a stack overflow if the object level is too deep.

## ◆ yyjson_mut_val_mut_copy()

yyjson_api yyjson_mut_val * yyjson_mut_val_mut_copy | ( | yyjson_mut_doc * | doc,
|  | yyjson_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.

Note
  `mut_val` -> `mut_val`.

Warning
  This function is recursive and may cause a stack overflow if the object level is too deep.

## ◆ yyjson_mut_val_write()

yyjson_api_inline char * yyjson_mut_val_write | ( | const yyjson_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.

Returns
  A 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_mut_val_write_file()

yyjson_api bool yyjson_mut_val_write_file | ( | const char * | path,
|  | const yyjson_mut_val * | val,
|  | yyjson_write_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_write_err * | err
| ) |  |

Write a value to JSON file with options.

This function is thread-safe when:

1. The file is not accessed by other threads.
2. The `val` is not modified by other threads.
3. The `alc` is thread-safe or NULL.

Parameters

  path | The JSON file's path. 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.

Returns
  true if successful, false if an error occurs.

Warning
  On 32-bit operating system, files larger than 2GB may fail to write.

## ◆ yyjson_mut_val_write_fp()

yyjson_api bool yyjson_mut_val_write_fp | ( | FILE * | fp,
|  | const yyjson_mut_val * | val,
|  | yyjson_write_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_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.

Returns
  true if successful, false if an error occurs.

Warning
  On 32-bit operating system, files larger than 2GB may fail to write.

## ◆ yyjson_mut_val_write_opts()

yyjson_api char * yyjson_mut_val_write_opts | ( | const yyjson_mut_val * | val,
|  | yyjson_write_flag | flg,
|  | const yyjson_alc * | alc,
|  | size_t * | len,
|  | yyjson_write_err * | err
| ) |  |

Write a value to JSON string with options.

This function is thread-safe when:

1. The `val` is not modified by other threads.
2. The `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.

Returns
  A 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_mut_write()

yyjson_api_inline char * yyjson_mut_write | ( | const yyjson_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.

Returns
  A 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_mut_write_file()

yyjson_api bool yyjson_mut_write_file | ( | const char * | path,
|  | const yyjson_mut_doc * | doc,
|  | yyjson_write_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_write_err * | err
| ) |  |

Write a document to JSON file with options.

This function is thread-safe when:

1. The file is not accessed by other threads.
2. The `doc` is not modified by other threads.
3. The `alc` is thread-safe or NULL.

Parameters

  path | The JSON file's path. 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.

Returns
  true if successful, false if an error occurs.

Warning
  On 32-bit operating system, files larger than 2GB may fail to write.

## ◆ yyjson_mut_write_fp()

yyjson_api bool yyjson_mut_write_fp | ( | FILE * | fp,
|  | const yyjson_mut_doc * | doc,
|  | yyjson_write_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_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.

Returns
  true if successful, false if an error occurs.

Warning
  On 32-bit operating system, files larger than 2GB may fail to write.

## ◆ yyjson_mut_write_opts()

yyjson_api char * yyjson_mut_write_opts | ( | const yyjson_mut_doc * | doc,
|  | yyjson_write_flag | flg,
|  | const yyjson_alc * | alc,
|  | size_t * | len,
|  | yyjson_write_err * | err
| ) |  |

Write a document to JSON string with options.

This function is thread-safe when:

1. The `doc` is not modified by other threads.
2. The `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.

Returns
  A 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_obj_get()

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.

Warning
  This function takes a linear search time.

## ◆ yyjson_obj_getn()

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.

Warning
  This function takes a linear search time.

## ◆ yyjson_obj_iter_get()

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.

Returns
  The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid.

Warning
  This function takes a linear search time if the key is not nearby.

## ◆ yyjson_obj_iter_get_val()

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_obj_iter_getn()

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.

Returns
  The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid.

Warning
  This function takes a linear search time if the key is not nearby.

## ◆ yyjson_obj_iter_has_next()

yyjson_api_inline bool yyjson_obj_iter_has_next | ( | yyjson_obj_iter * | iter | ) |

Returns whether the iteration has more elements. If `iter` is NULL, this function will return false.

## ◆ yyjson_obj_iter_init()

yyjson_api_inline bool yyjson_obj_iter_init | ( | yyjson_val * | obj,
|  | yyjson_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.

Returns
  true if the `iter` has been successfully initialized.

Note
  The iterator does not need to be destroyed.

## ◆ yyjson_obj_iter_next()

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_obj_iter_with()

yyjson_api_inline yyjson_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.

Returns
  A new iterator for the object.

Note
  The iterator does not need to be destroyed.

## ◆ yyjson_obj_size()

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_patch()

yyjson_api yyjson_mut_val * yyjson_patch | ( | yyjson_mut_doc * | doc,
|  | yyjson_val * | orig,
|  | yyjson_val * | patch,
|  | yyjson_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_ptr_ctx_append()

yyjson_api_inline bool yyjson_ptr_ctx_append | ( | yyjson_ptr_ctx * | ctx,
|  | yyjson_mut_val * | key,
|  | yyjson_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.

Returns
  true on success or false on fail.

## ◆ yyjson_ptr_ctx_remove()

yyjson_api_inline bool yyjson_ptr_ctx_remove | ( | yyjson_ptr_ctx * | ctx | ) |

Remove value by JSON pointer context.

Parameters

  ctx | The context from the `yyjson_mut_ptr_xxx()` calls.

Returns
  true on success or false on fail.

Note
  If success, the old value will be returned via `ctx->old`.

## ◆ yyjson_ptr_ctx_replace()

yyjson_api_inline bool yyjson_ptr_ctx_replace | ( | yyjson_ptr_ctx * | ctx,
|  | yyjson_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.

Returns
  true on success or false on fail.

Note
  If success, the old value will be returned via `ctx->old`.

## ◆ yyjson_ptr_get()

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).

Returns
  The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_ptr_get_bool()

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_ptr_get_num()

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_ptr_get_real()

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_ptr_get_sint()

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_ptr_get_str()

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_ptr_get_uint()

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_ptr_getn()

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.

Returns
  The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_ptr_getx()

yyjson_api_inline yyjson_val * yyjson_ptr_getx | ( | yyjson_val * | val,
|  | const char * | ptr,
|  | size_t | len,
|  | yyjson_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.

Returns
  The value referenced by the JSON pointer. NULL if `val` or `ptr` is NULL, or the JSON pointer cannot be resolved.

## ◆ yyjson_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.

Returns
  A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with `yyjson_doc_free()`.

## ◆ yyjson_read_file()

yyjson_api yyjson_doc * yyjson_read_file | ( | const char * | path,
|  | yyjson_read_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_read_err * | err
| ) |  |

Read a JSON file.

This function is thread-safe when:

1. The file is not modified by other threads.
2. The `alc` is thread-safe or NULL.

Parameters

  path | The JSON file's path. 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.

Returns
  A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with `yyjson_doc_free()`.

Warning
  On 32-bit operating system, files larger than 2GB may fail to read.

## ◆ yyjson_read_fp()

yyjson_api yyjson_doc * yyjson_read_fp | ( | FILE * | fp,
|  | yyjson_read_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_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.

Returns
  A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with `yyjson_doc_free()`.

Warning
  On 32-bit operating system, files larger than 2GB may fail to read.

## ◆ yyjson_read_max_memory_usage()

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.

Returns
  The 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_doc_free
  yyjson_api_inline void yyjson_doc_free(yyjson_doc *doc)
  Definition: yyjson.h:4851
  yyjson_read_max_memory_usage
  yyjson_api_inline size_t yyjson_read_max_memory_usage(size_t len, yyjson_read_flag flg)
  Definition: yyjson.h:999

See also
  yyjson_alc_pool_init()

## ◆ yyjson_read_number()

yyjson_api const char * yyjson_read_number | ( | const char * | dat,
|  | yyjson_val * | val,
|  | yyjson_read_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_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.

Returns
  If successful, a pointer to the character after the last character used in the conversion, NULL if an error occurs.

## ◆ yyjson_read_opts()

yyjson_api yyjson_doc * yyjson_read_opts | ( | char * | dat,
|  | size_t | len,
|  | yyjson_read_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_read_err * | err
| ) |  |

Read JSON with options.

This function is thread-safe when:

1. The `dat` is not modified by other threads.
2. The `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.

Returns
  A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with `yyjson_doc_free()`.

## ◆ yyjson_set_bool()

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.

Warning
  This will modify the `immutable` value, use with caution.

## ◆ yyjson_set_int()

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.

Warning
  This will modify the `immutable` value, use with caution.

## ◆ yyjson_set_null()

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.

Warning
  This will modify the `immutable` value, use with caution.

## ◆ yyjson_set_raw()

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.

Warning
  This will modify the `immutable` value, use with caution.

## ◆ yyjson_set_real()

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.

Warning
  This will modify the `immutable` value, use with caution.

## ◆ yyjson_set_sint()

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.

Warning
  This will modify the `immutable` value, use with caution.

## ◆ yyjson_set_str()

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.

Warning
  This will modify the `immutable` value, use with caution.

## ◆ yyjson_set_strn()

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.

Warning
  This will modify the `immutable` value, use with caution.

## ◆ yyjson_set_uint()

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.

Warning
  This will modify the `immutable` value, use with caution.

## ◆ yyjson_val_mut_copy()

yyjson_api yyjson_mut_val * yyjson_val_mut_copy | ( | yyjson_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.

Note
  `imut_val` -> `mut_val`.

## ◆ yyjson_val_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.

Returns
  A 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_val_write_file()

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 * | err
| ) |  |

Write a value to JSON file with options.

This function is thread-safe when:

1. The file is not accessed by other threads.
2. The `alc` is thread-safe or NULL.

Parameters

  path | The JSON file's path. 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.

Returns
  true if successful, false if an error occurs.

Warning
  On 32-bit operating system, files larger than 2GB may fail to write.

## ◆ yyjson_val_write_fp()

yyjson_api bool yyjson_val_write_fp | ( | FILE * | fp,
|  | const yyjson_val * | val,
|  | yyjson_write_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_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.

Returns
  true if successful, false if an error occurs.

Warning
  On 32-bit operating system, files larger than 2GB may fail to write.

## ◆ yyjson_val_write_opts()

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 * | 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.

Returns
  A 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_version()

yyjson_api uint32_t yyjson_version | ( | void |  | ) |

The version of yyjson in hex, same as `YYJSON_VERSION_HEX`.

## ◆ yyjson_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.

Returns
  A 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_write_file()

yyjson_api bool yyjson_write_file | ( | const char * | path,
|  | const yyjson_doc * | doc,
|  | yyjson_write_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_write_err * | err
| ) |  |

Write a document to JSON file with options.

This function is thread-safe when:

1. The file is not accessed by other threads.
2. The `alc` is thread-safe or NULL.

Parameters

  path | The JSON file's path. 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.

Returns
  true if successful, false if an error occurs.

Warning
  On 32-bit operating system, files larger than 2GB may fail to write.

## ◆ yyjson_write_fp()

yyjson_api bool yyjson_write_fp | ( | FILE * | fp,
|  | const yyjson_doc * | doc,
|  | yyjson_write_flag | flg,
|  | const yyjson_alc * | alc,
|  | yyjson_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.

Returns
  true if successful, false if an error occurs.

Warning
  On 32-bit operating system, files larger than 2GB may fail to write.

## ◆ yyjson_write_opts()

yyjson_api char * yyjson_write_opts | ( | const yyjson_doc * | doc,
|  | yyjson_write_flag | flg,
|  | const yyjson_alc * | alc,
|  | size_t * | len,
|  | yyjson_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.

Returns
  A 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().

## Variable Documentation

## ◆ YYJSON_PATCH_ERROR_EQUAL

const yyjson_patch_code YYJSON_PATCH_ERROR_EQUAL = 6
| static

JSON patch operation `test` not equal.

## ◆ YYJSON_PATCH_ERROR_INVALID_MEMBER

const yyjson_patch_code YYJSON_PATCH_ERROR_INVALID_MEMBER = 5
| static

JSON patch operation member is invalid.

## ◆ YYJSON_PATCH_ERROR_INVALID_OPERATION

const yyjson_patch_code YYJSON_PATCH_ERROR_INVALID_OPERATION = 3
| static

JSON patch operation is not object type.

## ◆ YYJSON_PATCH_ERROR_INVALID_PARAMETER

const yyjson_patch_code YYJSON_PATCH_ERROR_INVALID_PARAMETER = 1
| static

Invalid parameter, such as NULL input or non-array patch.

## ◆ YYJSON_PATCH_ERROR_MEMORY_ALLOCATION

const yyjson_patch_code YYJSON_PATCH_ERROR_MEMORY_ALLOCATION = 2
| static

Memory allocation failure occurs.

## ◆ YYJSON_PATCH_ERROR_MISSING_KEY

const yyjson_patch_code YYJSON_PATCH_ERROR_MISSING_KEY = 4
| static

JSON patch operation is missing a required key.

## ◆ YYJSON_PATCH_ERROR_POINTER

const yyjson_patch_code YYJSON_PATCH_ERROR_POINTER = 7
| static

JSON patch operation failed on JSON pointer.

## ◆ YYJSON_PATCH_SUCCESS

const yyjson_patch_code YYJSON_PATCH_SUCCESS = 0
| static

Success, no error.

## ◆ YYJSON_PTR_ERR_MEMORY_ALLOCATION

const yyjson_ptr_code YYJSON_PTR_ERR_MEMORY_ALLOCATION = 6
| static

The memory allocation failed and a new value could not be created.

## ◆ YYJSON_PTR_ERR_NONE

const yyjson_ptr_code YYJSON_PTR_ERR_NONE = 0
| static

No JSON pointer error.

## ◆ YYJSON_PTR_ERR_NULL_ROOT

const yyjson_ptr_code YYJSON_PTR_ERR_NULL_ROOT = 4
| static

Document's root is NULL, but it is required for the function call.

## ◆ YYJSON_PTR_ERR_PARAMETER

const yyjson_ptr_code YYJSON_PTR_ERR_PARAMETER = 1
| static

Invalid input parameter, such as NULL input.

## ◆ YYJSON_PTR_ERR_RESOLVE

const yyjson_ptr_code YYJSON_PTR_ERR_RESOLVE = 3
| static

JSON pointer resolve failed, such as index out of range, key not found.

## ◆ YYJSON_PTR_ERR_SET_ROOT

const yyjson_ptr_code YYJSON_PTR_ERR_SET_ROOT = 5
| static

Cannot set root as the target is not a document.

## ◆ YYJSON_PTR_ERR_SYNTAX

const yyjson_ptr_code YYJSON_PTR_ERR_SYNTAX = 2
| static

JSON pointer syntax error, such as invalid escape, token no prefix.

## ◆ YYJSON_READ_ALLOW_COMMENTS

const yyjson_read_flag YYJSON_READ_ALLOW_COMMENTS = 1 << 3
| static

Allow C-style single line and multiple line comments (non-standard).

## ◆ YYJSON_READ_ALLOW_INF_AND_NAN

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).

## ◆ YYJSON_READ_ALLOW_INVALID_UNICODE

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.

Warning
  Strings in JSON values may contain incorrect encoding when this option is used, you need to handle these strings carefully to avoid security risks.

## ◆ YYJSON_READ_ALLOW_TRAILING_COMMAS

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).

## ◆ YYJSON_READ_BIGNUM_AS_RAW

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.

## ◆ YYJSON_READ_ERROR_EMPTY_CONTENT

const yyjson_read_code YYJSON_READ_ERROR_EMPTY_CONTENT = 3
| static

Input JSON string is empty.

## ◆ YYJSON_READ_ERROR_FILE_OPEN

const yyjson_read_code YYJSON_READ_ERROR_FILE_OPEN = 12
| static

Failed to open a file.

## ◆ YYJSON_READ_ERROR_FILE_READ

const yyjson_read_code YYJSON_READ_ERROR_FILE_READ = 13
| static

Failed to read a file.

## ◆ YYJSON_READ_ERROR_INVALID_COMMENT

const yyjson_read_code YYJSON_READ_ERROR_INVALID_COMMENT = 8
| static

Invalid comment, such as unclosed multi-line comment.

## ◆ YYJSON_READ_ERROR_INVALID_NUMBER

const yyjson_read_code YYJSON_READ_ERROR_INVALID_NUMBER = 9
| static

Invalid number, such as `123.e12`, `000`.

## ◆ YYJSON_READ_ERROR_INVALID_PARAMETER

const yyjson_read_code YYJSON_READ_ERROR_INVALID_PARAMETER = 1
| static

Invalid parameter, such as NULL input string or 0 input length.

## ◆ YYJSON_READ_ERROR_INVALID_STRING

const yyjson_read_code YYJSON_READ_ERROR_INVALID_STRING = 10
| static

Invalid string, such as invalid escaped character inside a string.

## ◆ YYJSON_READ_ERROR_JSON_STRUCTURE

const yyjson_read_code YYJSON_READ_ERROR_JSON_STRUCTURE = 7
| static

Invalid JSON structure, such as `[1,]`.

## ◆ YYJSON_READ_ERROR_LITERAL

const yyjson_read_code YYJSON_READ_ERROR_LITERAL = 11
| static

Invalid JSON literal, such as `truu`.

## ◆ YYJSON_READ_ERROR_MEMORY_ALLOCATION

const yyjson_read_code YYJSON_READ_ERROR_MEMORY_ALLOCATION = 2
| static

Memory allocation failure occurs.

## ◆ YYJSON_READ_ERROR_UNEXPECTED_CHARACTER

const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_CHARACTER = 6
| static

Unexpected character inside the document, such as `[abc]`.

## ◆ YYJSON_READ_ERROR_UNEXPECTED_CONTENT

const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_CONTENT = 4
| static

Unexpected content after document, such as `[123]abc`.

## ◆ YYJSON_READ_ERROR_UNEXPECTED_END

const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_END = 5
| static

Unexpected ending, such as `[123`.

## ◆ YYJSON_READ_INSITU

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.

## ◆ YYJSON_READ_NOFLAG

const yyjson_read_flag YYJSON_READ_NOFLAG = 0
| static

Default option (RFC 8259 compliant):

- Read positive integer as uint64_t.
- Read negative integer as int64_t.
- Read floating-point number as double with round-to-nearest mode.
- Read integer which cannot fit in uint64_t or int64_t as double.
- Report error if double number is infinity.
- Report error if string contains invalid UTF-8 character or BOM.
- Report error on trailing commas, comments, inf and nan literals.

## ◆ YYJSON_READ_NUMBER_AS_RAW

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.

## ◆ YYJSON_READ_STOP_WHEN_DONE

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`.

## ◆ YYJSON_READ_SUCCESS

const yyjson_read_code YYJSON_READ_SUCCESS = 0
| static

Success, no error.

## ◆ YYJSON_WRITE_ALLOW_INF_AND_NAN

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).

## ◆ YYJSON_WRITE_ALLOW_INVALID_UNICODE

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.

## ◆ YYJSON_WRITE_ERROR_FILE_OPEN

const yyjson_write_code YYJSON_WRITE_ERROR_FILE_OPEN = 5
| static

Failed to open a file.

## ◆ YYJSON_WRITE_ERROR_FILE_WRITE

const yyjson_write_code YYJSON_WRITE_ERROR_FILE_WRITE = 6
| static

Failed to write a file.

## ◆ YYJSON_WRITE_ERROR_INVALID_PARAMETER

const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_PARAMETER = 1
| static

Invalid parameter, such as NULL document.

## ◆ YYJSON_WRITE_ERROR_INVALID_STRING

const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_STRING = 7
| static

Invalid unicode in string.

## ◆ YYJSON_WRITE_ERROR_INVALID_VALUE_TYPE

const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_VALUE_TYPE = 3
| static

Invalid value type in JSON document.

## ◆ YYJSON_WRITE_ERROR_MEMORY_ALLOCATION

const yyjson_write_code YYJSON_WRITE_ERROR_MEMORY_ALLOCATION = 2
| static

Memory allocation failure occurs.

## ◆ YYJSON_WRITE_ERROR_NAN_OR_INF

const yyjson_write_code YYJSON_WRITE_ERROR_NAN_OR_INF = 4
| static

NaN or Infinity number occurs.

## ◆ YYJSON_WRITE_ESCAPE_SLASHES

const yyjson_write_flag YYJSON_WRITE_ESCAPE_SLASHES = 1 << 2
| static

Escape '/' as '\/'.

## ◆ YYJSON_WRITE_ESCAPE_UNICODE

const yyjson_write_flag YYJSON_WRITE_ESCAPE_UNICODE = 1 << 1
| static

Escape unicode as `uXXXX`, make the output ASCII only.

## ◆ YYJSON_WRITE_INF_AND_NAN_AS_NULL

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.

## ◆ YYJSON_WRITE_NEWLINE_AT_END

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.

## ◆ YYJSON_WRITE_NOFLAG

const yyjson_write_flag YYJSON_WRITE_NOFLAG = 0
| static

Default option:

- Write JSON minify.
- Report error on inf or nan number.
- Report error on invalid UTF-8 string.
- Do not escape unicode or slash.

## ◆ YYJSON_WRITE_PRETTY

const yyjson_write_flag YYJSON_WRITE_PRETTY = 1 << 0
| static

Write JSON pretty with 4 space indent.

## ◆ YYJSON_WRITE_PRETTY_TWO_SPACES

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.

## ◆ YYJSON_WRITE_SUCCESS

const yyjson_write_code YYJSON_WRITE_SUCCESS = 0
| static

Success, no error.