Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
Loading...
Searching...
No Matches
yyjson.h File Reference
#include <stddef.h>
#include <limits.h>
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

Go to the source code of this file.

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_DISABLE_READER   0
#define YYJSON_DISABLE_WRITER   0
#define YYJSON_DISABLE_INCR_READER   0
#define YYJSON_DISABLE_FILE   0
#define YYJSON_DISABLE_UTILS   0
#define YYJSON_DISABLE_FAST_FP_CONV   0
#define YYJSON_DISABLE_NON_STANDARD   0
#define YYJSON_DISABLE_UTF8_VALIDATION   0
#define YYJSON_READER_DEPTH_LIMIT   0
#define YYJSON_FREESTANDING   0
#define YYJSON_MSC_VER   0
#define YYJSON_GCC_VER   0
#define yyjson_gcc_available(major, minor, patch)
#define YYJSON_IS_REAL_GCC   0
#define YYJSON_STDC_VER   0
#define YYJSON_CPP_VER   0
#define yyjson_has_builtin(x)
#define yyjson_has_attribute(x)
#define yyjson_has_feature(x)
#define yyjson_has_include(x)
#define yyjson_inline
#define yyjson_noinline
#define yyjson_align(x)
#define yyjson_likely(expr)
#define yyjson_unlikely(expr)
#define yyjson_assume(expr)
#define YYJSON_HAS_CONSTANT_P   0
#define yyjson_constant_p(value)
#define yyjson_deprecated(msg)
#define yyjson_api
#define yyjson_api_inline   static yyjson_inline
#define yyjson_constcast(type)
#define YYJSON_U64_TO_F64_NO_IMPL   0
#define __bool_true_false_are_defined   1
#define bool   unsigned char
#define true   1
#define false   0
#define YYJSON_VERSION_MAJOR   0
#define YYJSON_VERSION_MINOR   12
#define YYJSON_VERSION_PATCH   0
#define YYJSON_VERSION_HEX   0x000C00
#define YYJSON_VERSION_STRING   "0.12.0"
#define YYJSON_TYPE_NONE   ((uint8_t)0) /* _____000 */
#define YYJSON_TYPE_RAW   ((uint8_t)1) /* _____001 */
#define YYJSON_TYPE_NULL   ((uint8_t)2) /* _____010 */
#define YYJSON_TYPE_BOOL   ((uint8_t)3) /* _____011 */
#define YYJSON_TYPE_NUM   ((uint8_t)4) /* _____100 */
#define YYJSON_TYPE_STR   ((uint8_t)5) /* _____101 */
#define YYJSON_TYPE_ARR   ((uint8_t)6) /* _____110 */
#define YYJSON_TYPE_OBJ   ((uint8_t)7) /* _____111 */
#define YYJSON_SUBTYPE_NONE   ((uint8_t)(0 << 3)) /* ___00___ */
#define YYJSON_SUBTYPE_FALSE   ((uint8_t)(0 << 3)) /* ___00___ */
#define YYJSON_SUBTYPE_TRUE   ((uint8_t)(1 << 3)) /* ___01___ */
#define YYJSON_SUBTYPE_UINT   ((uint8_t)(0 << 3)) /* ___00___ */
#define YYJSON_SUBTYPE_SINT   ((uint8_t)(1 << 3)) /* ___01___ */
#define YYJSON_SUBTYPE_REAL   ((uint8_t)(2 << 3)) /* ___10___ */
#define YYJSON_SUBTYPE_NOESC   ((uint8_t)(1 << 3)) /* ___01___ */
#define YYJSON_TYPE_MASK   ((uint8_t)0x07) /* _____111 */
#define YYJSON_TYPE_BIT   ((uint8_t)3)
#define YYJSON_SUBTYPE_MASK   ((uint8_t)0x18) /* ___11___ */
#define YYJSON_SUBTYPE_BIT   ((uint8_t)2)
#define YYJSON_RESERVED_MASK   ((uint8_t)0xE0) /* 111_____ */
#define YYJSON_RESERVED_BIT   ((uint8_t)3)
#define YYJSON_TAG_MASK   ((uint8_t)0xFF) /* 11111111 */
#define YYJSON_TAG_BIT   ((uint8_t)8)
#define YYJSON_PADDING_SIZE   4
#define YYJSON_WRITE_FP_FLAG_BITS   8
#define YYJSON_WRITE_FP_PREC_BITS   4
#define YYJSON_WRITE_FP_TO_FIXED(prec)
#define YYJSON_WRITE_FP_TO_FLOAT   ((yyjson_write_flag)(1 << (32 - 5)))
#define yyjson_arr_foreach(arr, idx, max, val)
#define yyjson_obj_foreach(obj, idx, max, key, val)
#define yyjson_mut_arr_foreach(arr, idx, max, val)
#define yyjson_mut_obj_foreach(obj, idx, max, key, val)
#define yyjson_mut_val_one(func)
#define yyjson_mut_val_one_str(func)
#define yyjson_mut_arr_with_func(func)
#define yyjson_mut_obj_add_func(func)
#define yyjson_ptr_set_err(_code, _msg)

Typedefs

typedef uint8_t yyjson_type
typedef uint8_t yyjson_subtype
typedef struct yyjson_alc yyjson_alc
typedef struct yyjson_doc yyjson_doc
typedef struct yyjson_val yyjson_val
typedef struct yyjson_mut_doc yyjson_mut_doc
typedef struct yyjson_mut_val yyjson_mut_val
typedef uint32_t yyjson_read_flag
typedef uint32_t yyjson_read_code
typedef struct yyjson_read_err yyjson_read_err
typedef struct yyjson_incr_state yyjson_incr_state
typedef uint32_t yyjson_write_flag
typedef uint32_t yyjson_write_code
typedef struct yyjson_write_err yyjson_write_err
typedef struct yyjson_arr_iter yyjson_arr_iter
typedef struct yyjson_obj_iter yyjson_obj_iter
typedef struct yyjson_mut_arr_iter yyjson_mut_arr_iter
typedef struct yyjson_mut_obj_iter yyjson_mut_obj_iter
typedef uint32_t yyjson_ptr_code
typedef struct yyjson_ptr_err yyjson_ptr_err
typedef struct yyjson_ptr_ctx yyjson_ptr_ctx
typedef uint32_t yyjson_patch_code
typedef struct yyjson_patch_err yyjson_patch_err
typedef union yyjson_val_uni yyjson_val_uni
typedef struct yyjson_str_chunk yyjson_str_chunk
typedef struct yyjson_str_pool yyjson_str_pool
typedef struct yyjson_val_chunk yyjson_val_chunk
typedef struct yyjson_val_pool yyjson_val_pool

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_alcyyjson_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_docyyjson_read_opts (char *dat, size_t len, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)
yyjson_api yyjson_docyyjson_read_file (const char *path, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)
yyjson_api yyjson_docyyjson_read_fp (FILE *fp, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)
yyjson_api_inline yyjson_docyyjson_read (const char *dat, size_t len, yyjson_read_flag flg)
yyjson_api yyjson_incr_stateyyjson_incr_new (char *buf, size_t buf_len, yyjson_read_flag flg, const yyjson_alc *alc)
yyjson_api yyjson_docyyjson_incr_read (yyjson_incr_state *state, size_t len, yyjson_read_err *err)
yyjson_api void yyjson_incr_free (yyjson_incr_state *state)
yyjson_api_inline size_t yyjson_read_max_memory_usage (size_t len, yyjson_read_flag flg)
yyjson_api const char * yyjson_read_number (const char *dat, yyjson_val *val, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *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 size_t yyjson_write_buf (char *buf, size_t buf_len, const yyjson_doc *doc, yyjson_write_flag flg, 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 size_t yyjson_mut_write_buf (char *buf, size_t buf_len, const yyjson_mut_doc *doc, yyjson_write_flag flg, 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 size_t yyjson_val_write_buf (char *buf, size_t buf_len, const yyjson_val *val, yyjson_write_flag flg, 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 size_t yyjson_mut_val_write_buf (char *buf, size_t buf_len, const yyjson_mut_val *val, yyjson_write_flag flg, 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 char * yyjson_write_number (const yyjson_val *val, char *buf)
yyjson_api_inline char * yyjson_mut_write_number (const yyjson_mut_val *val, char *buf)
yyjson_api_inline yyjson_valyyjson_doc_get_root (const yyjson_doc *doc)
yyjson_api_inline size_t yyjson_doc_get_read_size (const yyjson_doc *doc)
yyjson_api_inline size_t yyjson_doc_get_val_count (const yyjson_doc *doc)
yyjson_api_inline void yyjson_doc_free (yyjson_doc *doc)
yyjson_api_inline bool yyjson_is_raw (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_null (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_true (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_false (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_bool (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_uint (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_sint (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_int (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_real (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_num (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_str (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_arr (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_obj (const yyjson_val *val)
yyjson_api_inline bool yyjson_is_ctn (const yyjson_val *val)
yyjson_api_inline yyjson_type yyjson_get_type (const yyjson_val *val)
yyjson_api_inline yyjson_subtype yyjson_get_subtype (const yyjson_val *val)
yyjson_api_inline uint8_t yyjson_get_tag (const yyjson_val *val)
yyjson_api_inline const char * yyjson_get_type_desc (const yyjson_val *val)
yyjson_api_inline const char * yyjson_get_raw (const yyjson_val *val)
yyjson_api_inline bool yyjson_get_bool (const yyjson_val *val)
yyjson_api_inline uint64_t yyjson_get_uint (const yyjson_val *val)
yyjson_api_inline int64_t yyjson_get_sint (const yyjson_val *val)
yyjson_api_inline int yyjson_get_int (const yyjson_val *val)
yyjson_api_inline double yyjson_get_real (const yyjson_val *val)
yyjson_api_inline double yyjson_get_num (const yyjson_val *val)
yyjson_api_inline const char * yyjson_get_str (const yyjson_val *val)
yyjson_api_inline size_t yyjson_get_len (const yyjson_val *val)
yyjson_api_inline bool yyjson_equals_str (const yyjson_val *val, const char *str)
yyjson_api_inline bool yyjson_equals_strn (const yyjson_val *val, const char *str, size_t len)
yyjson_api_inline bool yyjson_equals (const yyjson_val *lhs, const 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, int64_t num)
yyjson_api_inline bool yyjson_set_float (yyjson_val *val, float num)
yyjson_api_inline bool yyjson_set_double (yyjson_val *val, double num)
yyjson_api_inline bool yyjson_set_real (yyjson_val *val, double num)
yyjson_api_inline bool yyjson_set_fp_to_fixed (yyjson_val *val, int prec)
yyjson_api_inline bool yyjson_set_fp_to_float (yyjson_val *val, bool flt)
yyjson_api_inline bool yyjson_set_str (yyjson_val *val, const char *str)
yyjson_api_inline bool yyjson_set_strn (yyjson_val *val, const char *str, size_t len)
yyjson_api_inline bool yyjson_set_str_noesc (yyjson_val *val, bool noesc)
yyjson_api_inline size_t yyjson_arr_size (const yyjson_val *arr)
yyjson_api_inline yyjson_valyyjson_arr_get (const yyjson_val *arr, size_t idx)
yyjson_api_inline yyjson_valyyjson_arr_get_first (const yyjson_val *arr)
yyjson_api_inline yyjson_valyyjson_arr_get_last (const yyjson_val *arr)
yyjson_api_inline bool yyjson_arr_iter_init (const yyjson_val *arr, yyjson_arr_iter *iter)
yyjson_api_inline yyjson_arr_iter yyjson_arr_iter_with (const yyjson_val *arr)
yyjson_api_inline bool yyjson_arr_iter_has_next (yyjson_arr_iter *iter)
yyjson_api_inline yyjson_valyyjson_arr_iter_next (yyjson_arr_iter *iter)
yyjson_api_inline size_t yyjson_obj_size (const yyjson_val *obj)
yyjson_api_inline yyjson_valyyjson_obj_get (const yyjson_val *obj, const char *key)
yyjson_api_inline yyjson_valyyjson_obj_getn (const yyjson_val *obj, const char *key, size_t key_len)
yyjson_api_inline bool yyjson_obj_iter_init (const yyjson_val *obj, yyjson_obj_iter *iter)
yyjson_api_inline yyjson_obj_iter yyjson_obj_iter_with (const yyjson_val *obj)
yyjson_api_inline bool yyjson_obj_iter_has_next (yyjson_obj_iter *iter)
yyjson_api_inline yyjson_valyyjson_obj_iter_next (yyjson_obj_iter *iter)
yyjson_api_inline yyjson_valyyjson_obj_iter_get_val (yyjson_val *key)
yyjson_api_inline yyjson_valyyjson_obj_iter_get (yyjson_obj_iter *iter, const char *key)
yyjson_api_inline yyjson_valyyjson_obj_iter_getn (yyjson_obj_iter *iter, const char *key, size_t key_len)
yyjson_api_inline yyjson_mut_valyyjson_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_docyyjson_mut_doc_new (const yyjson_alc *alc)
yyjson_api yyjson_mut_docyyjson_doc_mut_copy (const yyjson_doc *doc, const yyjson_alc *alc)
yyjson_api yyjson_mut_docyyjson_mut_doc_mut_copy (const yyjson_mut_doc *doc, const yyjson_alc *alc)
yyjson_api yyjson_mut_valyyjson_val_mut_copy (yyjson_mut_doc *doc, const yyjson_val *val)
yyjson_api yyjson_mut_valyyjson_mut_val_mut_copy (yyjson_mut_doc *doc, const yyjson_mut_val *val)
yyjson_api yyjson_docyyjson_mut_doc_imut_copy (const yyjson_mut_doc *doc, const yyjson_alc *alc)
yyjson_api yyjson_docyyjson_mut_val_imut_copy (const yyjson_mut_val *val, const yyjson_alc *alc)
yyjson_api_inline bool yyjson_mut_is_raw (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_null (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_true (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_false (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_bool (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_uint (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_sint (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_int (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_real (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_num (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_str (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_arr (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_obj (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_is_ctn (const yyjson_mut_val *val)
yyjson_api_inline yyjson_type yyjson_mut_get_type (const yyjson_mut_val *val)
yyjson_api_inline yyjson_subtype yyjson_mut_get_subtype (const yyjson_mut_val *val)
yyjson_api_inline uint8_t yyjson_mut_get_tag (const yyjson_mut_val *val)
yyjson_api_inline const char * yyjson_mut_get_type_desc (const yyjson_mut_val *val)
yyjson_api_inline const char * yyjson_mut_get_raw (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_get_bool (const yyjson_mut_val *val)
yyjson_api_inline uint64_t yyjson_mut_get_uint (const yyjson_mut_val *val)
yyjson_api_inline int64_t yyjson_mut_get_sint (const yyjson_mut_val *val)
yyjson_api_inline int yyjson_mut_get_int (const yyjson_mut_val *val)
yyjson_api_inline double yyjson_mut_get_real (const yyjson_mut_val *val)
yyjson_api_inline double yyjson_mut_get_num (const yyjson_mut_val *val)
yyjson_api_inline const char * yyjson_mut_get_str (const yyjson_mut_val *val)
yyjson_api_inline size_t yyjson_mut_get_len (const yyjson_mut_val *val)
yyjson_api_inline bool yyjson_mut_equals_str (const yyjson_mut_val *val, const char *str)
yyjson_api_inline bool yyjson_mut_equals_strn (const yyjson_mut_val *val, const char *str, size_t len)
yyjson_api_inline bool yyjson_mut_equals (const yyjson_mut_val *lhs, const 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, int64_t num)
yyjson_api_inline bool yyjson_mut_set_float (yyjson_mut_val *val, float num)
yyjson_api_inline bool yyjson_mut_set_double (yyjson_mut_val *val, double num)
yyjson_api_inline bool yyjson_mut_set_real (yyjson_mut_val *val, double num)
yyjson_api_inline bool yyjson_mut_set_fp_to_fixed (yyjson_mut_val *val, int prec)
yyjson_api_inline bool yyjson_mut_set_fp_to_float (yyjson_mut_val *val, bool flt)
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_str_noesc (yyjson_mut_val *val, bool noesc)
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_valyyjson_mut_raw (yyjson_mut_doc *doc, const char *str)
yyjson_api_inline yyjson_mut_valyyjson_mut_rawn (yyjson_mut_doc *doc, const char *str, size_t len)
yyjson_api_inline yyjson_mut_valyyjson_mut_rawcpy (yyjson_mut_doc *doc, const char *str)
yyjson_api_inline yyjson_mut_valyyjson_mut_rawncpy (yyjson_mut_doc *doc, const char *str, size_t len)
yyjson_api_inline yyjson_mut_valyyjson_mut_null (yyjson_mut_doc *doc)
yyjson_api_inline yyjson_mut_valyyjson_mut_true (yyjson_mut_doc *doc)
yyjson_api_inline yyjson_mut_valyyjson_mut_false (yyjson_mut_doc *doc)
yyjson_api_inline yyjson_mut_valyyjson_mut_bool (yyjson_mut_doc *doc, bool val)
yyjson_api_inline yyjson_mut_valyyjson_mut_uint (yyjson_mut_doc *doc, uint64_t num)
yyjson_api_inline yyjson_mut_valyyjson_mut_sint (yyjson_mut_doc *doc, int64_t num)
yyjson_api_inline yyjson_mut_valyyjson_mut_int (yyjson_mut_doc *doc, int64_t num)
yyjson_api_inline yyjson_mut_valyyjson_mut_float (yyjson_mut_doc *doc, float num)
yyjson_api_inline yyjson_mut_valyyjson_mut_double (yyjson_mut_doc *doc, double num)
yyjson_api_inline yyjson_mut_valyyjson_mut_real (yyjson_mut_doc *doc, double num)
yyjson_api_inline yyjson_mut_valyyjson_mut_str (yyjson_mut_doc *doc, const char *str)
yyjson_api_inline yyjson_mut_valyyjson_mut_strn (yyjson_mut_doc *doc, const char *str, size_t len)
yyjson_api_inline yyjson_mut_valyyjson_mut_strcpy (yyjson_mut_doc *doc, const char *str)
yyjson_api_inline yyjson_mut_valyyjson_mut_strncpy (yyjson_mut_doc *doc, const char *str, size_t len)
yyjson_api_inline size_t yyjson_mut_arr_size (const yyjson_mut_val *arr)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_get (const yyjson_mut_val *arr, size_t idx)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_get_first (const yyjson_mut_val *arr)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_get_last (const 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_valyyjson_mut_arr_iter_next (yyjson_mut_arr_iter *iter)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_iter_remove (yyjson_mut_arr_iter *iter)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr (yyjson_mut_doc *doc)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_bool (yyjson_mut_doc *doc, const bool *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_sint (yyjson_mut_doc *doc, const int64_t *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_uint (yyjson_mut_doc *doc, const uint64_t *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_real (yyjson_mut_doc *doc, const double *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_sint8 (yyjson_mut_doc *doc, const int8_t *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_sint16 (yyjson_mut_doc *doc, const int16_t *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_sint32 (yyjson_mut_doc *doc, const int32_t *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_sint64 (yyjson_mut_doc *doc, const int64_t *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_uint8 (yyjson_mut_doc *doc, const uint8_t *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_uint16 (yyjson_mut_doc *doc, const uint16_t *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_uint32 (yyjson_mut_doc *doc, const uint32_t *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_uint64 (yyjson_mut_doc *doc, const uint64_t *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_float (yyjson_mut_doc *doc, const float *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_double (yyjson_mut_doc *doc, const double *vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_str (yyjson_mut_doc *doc, const char **vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_strn (yyjson_mut_doc *doc, const char **vals, const size_t *lens, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_with_strcpy (yyjson_mut_doc *doc, const char **vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_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_valyyjson_mut_arr_replace (yyjson_mut_val *arr, size_t idx, yyjson_mut_val *val)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_remove (yyjson_mut_val *arr, size_t idx)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_remove_first (yyjson_mut_val *arr)
yyjson_api_inline yyjson_mut_valyyjson_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_float (yyjson_mut_doc *doc, yyjson_mut_val *arr, float num)
yyjson_api_inline bool yyjson_mut_arr_add_double (yyjson_mut_doc *doc, yyjson_mut_val *arr, double 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_valyyjson_mut_arr_add_arr (yyjson_mut_doc *doc, yyjson_mut_val *arr)
yyjson_api_inline yyjson_mut_valyyjson_mut_arr_add_obj (yyjson_mut_doc *doc, yyjson_mut_val *arr)
yyjson_api_inline size_t yyjson_mut_obj_size (const yyjson_mut_val *obj)
yyjson_api_inline yyjson_mut_valyyjson_mut_obj_get (const yyjson_mut_val *obj, const char *key)
yyjson_api_inline yyjson_mut_valyyjson_mut_obj_getn (const 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_valyyjson_mut_obj_iter_next (yyjson_mut_obj_iter *iter)
yyjson_api_inline yyjson_mut_valyyjson_mut_obj_iter_get_val (yyjson_mut_val *key)
yyjson_api_inline yyjson_mut_valyyjson_mut_obj_iter_remove (yyjson_mut_obj_iter *iter)
yyjson_api_inline yyjson_mut_valyyjson_mut_obj_iter_get (yyjson_mut_obj_iter *iter, const char *key)
yyjson_api_inline yyjson_mut_valyyjson_mut_obj_iter_getn (yyjson_mut_obj_iter *iter, const char *key, size_t key_len)
yyjson_api_inline yyjson_mut_valyyjson_mut_obj (yyjson_mut_doc *doc)
yyjson_api_inline yyjson_mut_valyyjson_mut_obj_with_str (yyjson_mut_doc *doc, const char **keys, const char **vals, size_t count)
yyjson_api_inline yyjson_mut_valyyjson_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_valyyjson_mut_obj_remove (yyjson_mut_val *obj, yyjson_mut_val *key)
yyjson_api_inline yyjson_mut_valyyjson_mut_obj_remove_key (yyjson_mut_val *obj, const char *key)
yyjson_api_inline yyjson_mut_valyyjson_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_float (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, float val)
yyjson_api_inline bool yyjson_mut_obj_add_double (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, double 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_valyyjson_mut_obj_add_arr (yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key)
yyjson_api_inline yyjson_mut_valyyjson_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_valyyjson_mut_obj_remove_str (yyjson_mut_val *obj, const char *key)
yyjson_api_inline yyjson_mut_valyyjson_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_valyyjson_doc_ptr_get (const yyjson_doc *doc, const char *ptr)
yyjson_api_inline yyjson_valyyjson_doc_ptr_getn (const yyjson_doc *doc, const char *ptr, size_t len)
yyjson_api_inline yyjson_valyyjson_doc_ptr_getx (const yyjson_doc *doc, const char *ptr, size_t len, yyjson_ptr_err *err)
yyjson_api_inline yyjson_valyyjson_ptr_get (const yyjson_val *val, const char *ptr)
yyjson_api_inline yyjson_valyyjson_ptr_getn (const yyjson_val *val, const char *ptr, size_t len)
yyjson_api_inline yyjson_valyyjson_ptr_getx (const yyjson_val *val, const char *ptr, size_t len, yyjson_ptr_err *err)
yyjson_api_inline yyjson_mut_valyyjson_mut_doc_ptr_get (const yyjson_mut_doc *doc, const char *ptr)
yyjson_api_inline yyjson_mut_valyyjson_mut_doc_ptr_getn (const yyjson_mut_doc *doc, const char *ptr, size_t len)
yyjson_api_inline yyjson_mut_valyyjson_mut_doc_ptr_getx (const yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api_inline yyjson_mut_valyyjson_mut_ptr_get (const yyjson_mut_val *val, const char *ptr)
yyjson_api_inline yyjson_mut_valyyjson_mut_ptr_getn (const yyjson_mut_val *val, const char *ptr, size_t len)
yyjson_api_inline yyjson_mut_valyyjson_mut_ptr_getx (const 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_valyyjson_mut_doc_ptr_replace (yyjson_mut_doc *doc, const char *ptr, yyjson_mut_val *new_val)
yyjson_api_inline yyjson_mut_valyyjson_mut_doc_ptr_replacen (yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val)
yyjson_api_inline yyjson_mut_valyyjson_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_valyyjson_mut_ptr_replace (yyjson_mut_val *val, const char *ptr, yyjson_mut_val *new_val)
yyjson_api_inline yyjson_mut_valyyjson_mut_ptr_replacen (yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val)
yyjson_api_inline yyjson_mut_valyyjson_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_valyyjson_mut_doc_ptr_remove (yyjson_mut_doc *doc, const char *ptr)
yyjson_api_inline yyjson_mut_valyyjson_mut_doc_ptr_removen (yyjson_mut_doc *doc, const char *ptr, size_t len)
yyjson_api_inline yyjson_mut_valyyjson_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_valyyjson_mut_ptr_remove (yyjson_mut_val *val, const char *ptr)
yyjson_api_inline yyjson_mut_valyyjson_mut_ptr_removen (yyjson_mut_val *val, const char *ptr, size_t len)
yyjson_api_inline yyjson_mut_valyyjson_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_valyyjson_patch (yyjson_mut_doc *doc, const yyjson_val *orig, const yyjson_val *patch, yyjson_patch_err *err)
yyjson_api yyjson_mut_valyyjson_mut_patch (yyjson_mut_doc *doc, const yyjson_mut_val *orig, const yyjson_mut_val *patch, yyjson_patch_err *err)
yyjson_api yyjson_mut_valyyjson_merge_patch (yyjson_mut_doc *doc, const yyjson_val *orig, const yyjson_val *patch)
yyjson_api yyjson_mut_valyyjson_mut_merge_patch (yyjson_mut_doc *doc, const yyjson_mut_val *orig, const yyjson_mut_val *patch)
yyjson_api_inline bool unsafe_yyjson_is_str_noesc (const char *str, size_t len)
yyjson_api_inline double unsafe_yyjson_u64_to_f64 (uint64_t num)
yyjson_api_inline yyjson_type unsafe_yyjson_get_type (const void *val)
yyjson_api_inline yyjson_subtype unsafe_yyjson_get_subtype (const void *val)
yyjson_api_inline uint8_t unsafe_yyjson_get_tag (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_raw (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_null (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_bool (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_num (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_str (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_arr (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_obj (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_ctn (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_uint (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_sint (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_int (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_real (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_true (const void *val)
yyjson_api_inline bool unsafe_yyjson_is_false (const void *val)
yyjson_api_inline bool unsafe_yyjson_arr_is_flat (const yyjson_val *val)
yyjson_api_inline const char * unsafe_yyjson_get_raw (const void *val)
yyjson_api_inline bool unsafe_yyjson_get_bool (const void *val)
yyjson_api_inline uint64_t unsafe_yyjson_get_uint (const void *val)
yyjson_api_inline int64_t unsafe_yyjson_get_sint (const void *val)
yyjson_api_inline int unsafe_yyjson_get_int (const void *val)
yyjson_api_inline double unsafe_yyjson_get_real (const void *val)
yyjson_api_inline double unsafe_yyjson_get_num (const void *val)
yyjson_api_inline const char * unsafe_yyjson_get_str (const void *val)
yyjson_api_inline size_t unsafe_yyjson_get_len (const void *val)
yyjson_api_inline yyjson_valunsafe_yyjson_get_first (const yyjson_val *ctn)
yyjson_api_inline yyjson_valunsafe_yyjson_get_next (const yyjson_val *val)
yyjson_api_inline bool unsafe_yyjson_equals_strn (const void *val, const char *str, size_t len)
yyjson_api_inline bool unsafe_yyjson_equals_str (const void *val, const char *str)
yyjson_api_inline void unsafe_yyjson_set_type (void *val, yyjson_type type, yyjson_subtype subtype)
yyjson_api_inline void unsafe_yyjson_set_len (void *val, size_t len)
yyjson_api_inline void unsafe_yyjson_set_tag (void *val, yyjson_type type, yyjson_subtype subtype, size_t len)
yyjson_api_inline void unsafe_yyjson_inc_len (void *val)
yyjson_api_inline void unsafe_yyjson_set_raw (void *val, const char *raw, size_t len)
yyjson_api_inline void unsafe_yyjson_set_null (void *val)
yyjson_api_inline void unsafe_yyjson_set_bool (void *val, bool num)
yyjson_api_inline void unsafe_yyjson_set_uint (void *val, uint64_t num)
yyjson_api_inline void unsafe_yyjson_set_sint (void *val, int64_t num)
yyjson_api_inline void unsafe_yyjson_set_fp_to_fixed (void *val, int prec)
yyjson_api_inline void unsafe_yyjson_set_fp_to_float (void *val, bool flt)
yyjson_api_inline void unsafe_yyjson_set_float (void *val, float num)
yyjson_api_inline void unsafe_yyjson_set_double (void *val, double num)
yyjson_api_inline void unsafe_yyjson_set_real (void *val, double num)
yyjson_api_inline void unsafe_yyjson_set_str_noesc (void *val, bool noesc)
yyjson_api_inline void unsafe_yyjson_set_strn (void *val, const char *str, size_t len)
yyjson_api_inline void unsafe_yyjson_set_str (void *val, const char *str)
yyjson_api_inline void unsafe_yyjson_set_arr (void *val, size_t size)
yyjson_api_inline void unsafe_yyjson_set_obj (void *val, size_t size)
yyjson_api bool unsafe_yyjson_equals (const yyjson_val *lhs, const yyjson_val *rhs)
yyjson_api bool unsafe_yyjson_str_pool_grow (yyjson_str_pool *pool, const yyjson_alc *alc, size_t len)
yyjson_api bool unsafe_yyjson_val_pool_grow (yyjson_val_pool *pool, const yyjson_alc *alc, size_t count)
yyjson_api_inline char * unsafe_yyjson_mut_str_alc (yyjson_mut_doc *doc, size_t len)
yyjson_api_inline char * unsafe_yyjson_mut_strncpy (yyjson_mut_doc *doc, const char *str, size_t len)
yyjson_api_inline yyjson_mut_valunsafe_yyjson_mut_val (yyjson_mut_doc *doc, size_t count)
yyjson_api bool unsafe_yyjson_mut_equals (const yyjson_mut_val *lhs, const yyjson_mut_val *rhs)
yyjson_api_inline void unsafe_yyjson_mut_obj_add (yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val, size_t len)
yyjson_api_inline yyjson_mut_valunsafe_yyjson_mut_obj_remove (yyjson_mut_val *obj, const char *key, size_t key_len)
yyjson_api_inline bool unsafe_yyjson_mut_obj_replace (yyjson_mut_val *obj, yyjson_mut_val *key, yyjson_mut_val *val)
yyjson_api_inline void unsafe_yyjson_mut_obj_rotate (yyjson_mut_val *obj, size_t idx)
yyjson_api yyjson_valunsafe_yyjson_ptr_getx (const yyjson_val *val, const char *ptr, size_t len, yyjson_ptr_err *err)
yyjson_api yyjson_mut_valunsafe_yyjson_mut_ptr_getx (const yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api bool unsafe_yyjson_mut_ptr_putx (yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, bool insert_new, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
yyjson_api yyjson_mut_valunsafe_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 yyjson_mut_valunsafe_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_get_bool (const yyjson_val *root, const char *ptr, bool *value)
yyjson_api_inline bool yyjson_ptr_get_uint (const yyjson_val *root, const char *ptr, uint64_t *value)
yyjson_api_inline bool yyjson_ptr_get_sint (const yyjson_val *root, const char *ptr, int64_t *value)
yyjson_api_inline bool yyjson_ptr_get_real (const yyjson_val *root, const char *ptr, double *value)
yyjson_api_inline bool yyjson_ptr_get_num (const yyjson_val *root, const char *ptr, double *value)
yyjson_api_inline bool yyjson_ptr_get_str (const 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
return unsafe_yyjson_ptr_getx (val, ptr, len, &err)
 yyjson_deprecated ("renamed to unsafe_yyjson_mut_ptr_getx") yyjson_api_inline yyjson_mut_val *unsafe_yyjson_mut_get_pointer(yyjson_mut_val *val
return unsafe_yyjson_mut_ptr_getx (val, ptr, len, NULL, &err)

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_flag YYJSON_READ_ALLOW_BOM = 1 << 8
static const yyjson_read_flag YYJSON_READ_ALLOW_EXT_NUMBER = 1 << 9
static const yyjson_read_flag YYJSON_READ_ALLOW_EXT_ESCAPE = 1 << 10
static const yyjson_read_flag YYJSON_READ_ALLOW_EXT_WHITESPACE = 1 << 11
static const yyjson_read_flag YYJSON_READ_ALLOW_SINGLE_QUOTED_STR = 1 << 12
static const yyjson_read_flag YYJSON_READ_ALLOW_UNQUOTED_KEY = 1 << 13
static const yyjson_read_flag YYJSON_READ_JSON5
static const yyjson_read_code YYJSON_READ_SUCCESS = 0
static const yyjson_read_code YYJSON_READ_ERROR_INVALID_PARAMETER = 1
static const yyjson_read_code YYJSON_READ_ERROR_MEMORY_ALLOCATION = 2
static const yyjson_read_code YYJSON_READ_ERROR_EMPTY_CONTENT = 3
static const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_CONTENT = 4
static const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_END = 5
static const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_CHARACTER = 6
static const yyjson_read_code YYJSON_READ_ERROR_JSON_STRUCTURE = 7
static const yyjson_read_code YYJSON_READ_ERROR_INVALID_COMMENT = 8
static const yyjson_read_code YYJSON_READ_ERROR_INVALID_NUMBER = 9
static const yyjson_read_code YYJSON_READ_ERROR_INVALID_STRING = 10
static const yyjson_read_code YYJSON_READ_ERROR_LITERAL = 11
static const yyjson_read_code YYJSON_READ_ERROR_FILE_OPEN = 12
static const yyjson_read_code YYJSON_READ_ERROR_FILE_READ = 13
static const yyjson_read_code YYJSON_READ_ERROR_MORE = 14
static const yyjson_read_code YYJSON_READ_ERROR_DEPTH = 15
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_flag YYJSON_WRITE_LOWERCASE_HEX = 1 << 8
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
const char * ptr
const char size_t len

Detailed Description

Date
2019-03-09
Author
YaoYuan

Definition in file yyjson.h.

Macro Definition Documentation

◆ __bool_true_false_are_defined

#define __bool_true_false_are_defined   1

freestanding stdint (C89 compatible) stdbool (C89 compatible)

Definition at line 511 of file yyjson.h.

◆ bool

#define bool   unsigned char

◆ false

#define false   0

Definition at line 524 of file yyjson.h.

◆ true

#define true   1

Definition at line 523 of file yyjson.h.

◆ yyjson_align

#define yyjson_align ( x)

align for compiler

Definition at line 272 of file yyjson.h.

◆ yyjson_api

#define yyjson_api

function export

Definition at line 344 of file yyjson.h.

◆ yyjson_api_inline

◆ 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_api_inline yyjson_val * yyjson_arr_get_first(const yyjson_val *arr)
Definition yyjson.h:5619
yyjson_api_inline yyjson_val * unsafe_yyjson_get_next(const yyjson_val *val)
Definition yyjson.h:5191
yyjson_api_inline size_t yyjson_arr_size(const yyjson_val *arr)
Definition yyjson.h:5599

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

Example

size_t idx, max;
yyjson_arr_foreach(arr, idx, max, val) {
your_func(idx, val);
}
#define yyjson_arr_foreach(arr, idx, max, val)
Definition yyjson.h:2247

Definition at line 2247 of file yyjson.h.

◆ yyjson_assume

#define yyjson_assume ( expr)
Value:
((void)0)

assume for compiler

Definition at line 303 of file yyjson.h.

◆ yyjson_constant_p

#define yyjson_constant_p ( value)
Value:
0

Definition at line 313 of file yyjson.h.

Referenced by unsafe_yyjson_is_str_noesc().

◆ yyjson_constcast

#define yyjson_constcast ( type)
Value:
(type)(void *)(size_t)(const void *)

Used to cast away (remove) const qualifier.

Definition at line 355 of file yyjson.h.

◆ YYJSON_CPP_VER

#define YYJSON_CPP_VER   0

C++ version

Definition at line 196 of file yyjson.h.

◆ yyjson_deprecated

#define yyjson_deprecated ( msg)

deprecate warning

Definition at line 327 of file yyjson.h.

◆ YYJSON_DISABLE_FAST_FP_CONV

#define YYJSON_DISABLE_FAST_FP_CONV   0

Definition at line 75 of file yyjson.h.

◆ YYJSON_DISABLE_FILE

#define YYJSON_DISABLE_FILE   0

Definition at line 60 of file yyjson.h.

◆ YYJSON_DISABLE_INCR_READER

#define YYJSON_DISABLE_INCR_READER   0

Definition at line 55 of file yyjson.h.

◆ YYJSON_DISABLE_NON_STANDARD

#define YYJSON_DISABLE_NON_STANDARD   0

Definition at line 83 of file yyjson.h.

◆ YYJSON_DISABLE_READER

#define YYJSON_DISABLE_READER   0

Definition at line 42 of file yyjson.h.

◆ YYJSON_DISABLE_UTF8_VALIDATION

#define YYJSON_DISABLE_UTF8_VALIDATION   0

Definition at line 102 of file yyjson.h.

◆ YYJSON_DISABLE_UTILS

#define YYJSON_DISABLE_UTILS   0

Definition at line 66 of file yyjson.h.

◆ YYJSON_DISABLE_WRITER

#define YYJSON_DISABLE_WRITER   0

Definition at line 49 of file yyjson.h.

◆ YYJSON_FREESTANDING

#define YYJSON_FREESTANDING   0

Definition at line 126 of file yyjson.h.

◆ yyjson_gcc_available

#define yyjson_gcc_available ( major,
minor,
patch )
Value:
0

Definition at line 172 of file yyjson.h.

◆ YYJSON_GCC_VER

#define YYJSON_GCC_VER   0

compiler version (GCC)

Definition at line 171 of file yyjson.h.

◆ yyjson_has_attribute

#define yyjson_has_attribute ( x)
Value:
0

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

Definition at line 213 of file yyjson.h.

◆ yyjson_has_builtin

#define yyjson_has_builtin ( x)
Value:
0

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

Definition at line 204 of file yyjson.h.

◆ YYJSON_HAS_CONSTANT_P

#define YYJSON_HAS_CONSTANT_P   0

compile-time constant check for compiler

Definition at line 312 of file yyjson.h.

◆ yyjson_has_feature

#define yyjson_has_feature ( x)
Value:
0

compiler feature check (since clang 2.6, icc 17)

Definition at line 222 of file yyjson.h.

◆ yyjson_has_include

#define yyjson_has_include ( x)
Value:
0

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

Definition at line 231 of file yyjson.h.

◆ yyjson_inline

#define yyjson_inline

inline for compiler

Definition at line 248 of file yyjson.h.

◆ YYJSON_IS_REAL_GCC

#define YYJSON_IS_REAL_GCC   0

real gcc check

Definition at line 182 of file yyjson.h.

◆ yyjson_likely

#define yyjson_likely ( expr)
Value:
(expr)

likely for compiler

Definition at line 282 of file yyjson.h.

◆ YYJSON_MSC_VER

#define YYJSON_MSC_VER   0

compiler version (MSVC)

Definition at line 155 of file yyjson.h.

◆ 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_val * next
Definition yyjson.h:5803
yyjson_api_inline size_t yyjson_mut_arr_size(const yyjson_mut_val *arr)
Definition yyjson.h:6314
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_get_first(const yyjson_mut_val *arr)
Definition yyjson.h:6328

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_arr_foreach(arr, idx, max, val) {
your_func(idx, val);
}
#define yyjson_mut_arr_foreach(arr, idx, max, val)
Definition yyjson.h:2987

Definition at line 2987 of file yyjson.h.

Referenced by find_mut_array_item_by_long_field_runtime(), generated_surface_normalize_order_mut_runtime(), handle_action_route(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_mutate_command(), handle_state_named_command(), and revoke_session_by_cookie_runtime().

◆ yyjson_mut_arr_with_func

#define yyjson_mut_arr_with_func ( func)
Value:
if (yyjson_likely(doc && ((0 < count && count < \
(~(size_t)0) / sizeof(yyjson_mut_val) && vals) || count == 0))) { \
yyjson_mut_val *arr = unsafe_yyjson_mut_val(doc, 1 + count); \
if (yyjson_likely(arr)) { \
arr->tag = ((uint64_t)count << YYJSON_TAG_BIT) | YYJSON_TYPE_ARR; \
if (count > 0) { \
size_t i; \
for (i = 0; i < count; i++) { \
yyjson_mut_val *val = arr + i + 1; \
func \
val->next = val + 1; \
} \
arr[count].next = arr + 1; \
arr->uni.ptr = arr + count; \
} \
return arr; \
} \
} \
return NULL
yyjson_val_uni uni
Definition yyjson.h:5802
uint64_t tag
Definition yyjson.h:5801
#define yyjson_likely(expr)
Definition yyjson.h:282
yyjson_api_inline yyjson_mut_val * unsafe_yyjson_mut_val(yyjson_mut_doc *doc, size_t count)
Definition yyjson.h:5894
#define YYJSON_TYPE_ARR
Definition yyjson.h:609
#define YYJSON_TAG_BIT
Definition yyjson.h:645

Definition at line 6421 of file yyjson.h.

◆ yyjson_mut_obj_add_func

#define yyjson_mut_obj_add_func ( func)
Value:
if (yyjson_likely(doc && yyjson_mut_is_obj(obj) && _key)) { \
if (yyjson_likely(key)) { \
size_t len = unsafe_yyjson_get_len(obj); \
yyjson_mut_val *val = key + 1; \
size_t key_len = strlen(_key); \
bool noesc = unsafe_yyjson_is_str_noesc(_key, key_len); \
key->tag = YYJSON_TYPE_STR; \
key->tag |= (uint64_t)strlen(_key) << YYJSON_TAG_BIT; \
key->uni.str = _key; \
func \
unsafe_yyjson_mut_obj_add(obj, key, val, len); \
return true; \
} \
} \
return false
const char * str
Definition yyjson.h:4960
#define YYJSON_SUBTYPE_NONE
Definition yyjson.h:616
#define YYJSON_TYPE_STR
Definition yyjson.h:607
yyjson_api_inline bool yyjson_mut_is_obj(const yyjson_mut_val *val)
Definition yyjson.h:5978
const char size_t len
Definition yyjson.h:8364
yyjson_api_inline size_t unsafe_yyjson_get_len(const void *val)
Definition yyjson.h:5183
#define YYJSON_SUBTYPE_NOESC
Definition yyjson.h:628
yyjson_api_inline bool unsafe_yyjson_is_str_noesc(const char *str, size_t len)
Definition yyjson.h:5007

Definition at line 7367 of file yyjson.h.

◆ 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_api_inline size_t yyjson_mut_obj_size(const yyjson_mut_val *obj)
Definition yyjson.h:6966

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_mut_val *key, *val;
yyjson_mut_obj_foreach(obj, idx, max, key, val) {
your_func(key, val);
}
#define yyjson_mut_obj_foreach(obj, idx, max, key, val)
Definition yyjson.h:3859

Definition at line 3859 of file yyjson.h.

Referenced by yyjson_mut_merge_patch().

◆ yyjson_mut_val_one

#define yyjson_mut_val_one ( func)
Value:
if (yyjson_likely(doc)) { \
if (yyjson_likely(val)) { \
func \
return val; \
} \
} \
return NULL

Definition at line 6173 of file yyjson.h.

◆ yyjson_mut_val_one_str

#define yyjson_mut_val_one_str ( func)
Value:
if (yyjson_likely(doc && str)) { \
if (yyjson_likely(val)) { \
func \
return val; \
} \
} \
return NULL

Definition at line 6183 of file yyjson.h.

◆ yyjson_noinline

#define yyjson_noinline

noinline for compiler

Definition at line 259 of file yyjson.h.

◆ 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_api_inline size_t yyjson_obj_size(const yyjson_val *obj)
Definition yyjson.h:5689
yyjson_api_inline yyjson_val * unsafe_yyjson_get_first(const yyjson_val *ctn)
Definition yyjson.h:5187

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

Example

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

Definition at line 2419 of file yyjson.h.

Referenced by yyjson_merge_patch().

◆ YYJSON_PADDING_SIZE

#define YYJSON_PADDING_SIZE   4

Padding size for JSON reader.

Definition at line 648 of file yyjson.h.

Referenced by yyjson_incr_new(), yyjson_read_fp(), and yyjson_read_opts().

◆ yyjson_ptr_set_err

#define yyjson_ptr_set_err ( _code,
_msg )
Value:
do { \
if (err) { \
err->code = YYJSON_PTR_ERR_##_code; \
err->msg = _msg; \
err->pos = 0; \
} \
} while(false)

Definition at line 7594 of file yyjson.h.

◆ YYJSON_READER_DEPTH_LIMIT

#define YYJSON_READER_DEPTH_LIMIT   0

Definition at line 115 of file yyjson.h.

Referenced by read_root_minify(), read_root_pretty(), and yyjson_incr_read().

◆ YYJSON_RESERVED_BIT

#define YYJSON_RESERVED_BIT   ((uint8_t)3)

The number of reserved bits.

Definition at line 641 of file yyjson.h.

◆ YYJSON_RESERVED_MASK

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

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

Definition at line 639 of file yyjson.h.

◆ YYJSON_STDC_VER

#define YYJSON_STDC_VER   0

C version (STDC)

Definition at line 189 of file yyjson.h.

◆ YYJSON_SUBTYPE_BIT

#define YYJSON_SUBTYPE_BIT   ((uint8_t)2)

The number of bits used by the subtype.

Definition at line 637 of file yyjson.h.

◆ YYJSON_SUBTYPE_FALSE

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

False subtype: false literal.

Definition at line 618 of file yyjson.h.

Referenced by read_false().

◆ YYJSON_SUBTYPE_MASK

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

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

Definition at line 635 of file yyjson.h.

◆ YYJSON_SUBTYPE_NOESC

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

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

Definition at line 628 of file yyjson.h.

Referenced by read_str_opt().

◆ YYJSON_SUBTYPE_NONE

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

No subtype.

Definition at line 616 of file yyjson.h.

◆ YYJSON_SUBTYPE_REAL

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

Real number subtype: double.

Definition at line 626 of file yyjson.h.

Referenced by read_inf(), read_nan(), read_num(), write_num(), and yyjson_write_number().

◆ YYJSON_SUBTYPE_SINT

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

Signed integer subtype: int64_t.

Definition at line 624 of file yyjson.h.

Referenced by unsafe_yyjson_num_equals(), write_num(), and yyjson_write_number().

◆ YYJSON_SUBTYPE_TRUE

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

True subtype: true literal.

Definition at line 620 of file yyjson.h.

Referenced by read_true().

◆ YYJSON_SUBTYPE_UINT

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

Unsigned integer subtype: uint64_t.

Definition at line 622 of file yyjson.h.

Referenced by unsafe_yyjson_num_equals(), and yyjson_write_number().

◆ YYJSON_TAG_BIT

#define YYJSON_TAG_BIT   ((uint8_t)8)

The number of bits used by the tag.

Definition at line 645 of file yyjson.h.

Referenced by read_inf(), read_nan(), read_num_hex(), read_root_minify(), read_root_pretty(), read_str_opt(), and yyjson_incr_read().

◆ YYJSON_TAG_MASK

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

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

Definition at line 643 of file yyjson.h.

Referenced by read_root_minify(), read_root_pretty(), yyjson_incr_read(), and yyjson_write_number().

◆ YYJSON_TYPE_ARR

◆ YYJSON_TYPE_BIT

#define YYJSON_TYPE_BIT   ((uint8_t)3)

The number of bits used by the type.

Definition at line 633 of file yyjson.h.

◆ YYJSON_TYPE_BOOL

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

◆ YYJSON_TYPE_MASK

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

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

Definition at line 631 of file yyjson.h.

Referenced by read_root_minify(), read_root_pretty(), and yyjson_incr_read().

◆ YYJSON_TYPE_NONE

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

No type, invalid.

Definition at line 597 of file yyjson.h.

◆ YYJSON_TYPE_NULL

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

◆ YYJSON_TYPE_NUM

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

◆ YYJSON_TYPE_OBJ

◆ YYJSON_TYPE_RAW

◆ YYJSON_TYPE_STR

◆ YYJSON_U64_TO_F64_NO_IMPL

#define YYJSON_U64_TO_F64_NO_IMPL   0

Microsoft Visual C++ 6.0 doesn't support converting number from u64 to f64: error C2520: conversion from unsigned __int64 to double not implemented.

Definition at line 364 of file yyjson.h.

◆ yyjson_unlikely

#define yyjson_unlikely ( expr)
Value:
(expr)

unlikely for compiler

Definition at line 292 of file yyjson.h.

◆ YYJSON_VERSION_HEX

#define YYJSON_VERSION_HEX   0x000C00

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

Definition at line 580 of file yyjson.h.

Referenced by yyjson_version().

◆ YYJSON_VERSION_MAJOR

#define YYJSON_VERSION_MAJOR   0

char bit check The major version of yyjson.

Definition at line 571 of file yyjson.h.

◆ YYJSON_VERSION_MINOR

#define YYJSON_VERSION_MINOR   12

The minor version of yyjson.

Definition at line 574 of file yyjson.h.

◆ YYJSON_VERSION_PATCH

#define YYJSON_VERSION_PATCH   0

The patch version of yyjson.

Definition at line 577 of file yyjson.h.

◆ YYJSON_VERSION_STRING

#define YYJSON_VERSION_STRING   "0.12.0"

The version string of yyjson.

Definition at line 583 of file yyjson.h.

◆ YYJSON_WRITE_FP_FLAG_BITS

#define YYJSON_WRITE_FP_FLAG_BITS   8

The highest 8 bits of yyjson_write_flag and real number value's tag are reserved for controlling the output format of floating-point numbers.

Definition at line 1286 of file yyjson.h.

Referenced by write_num(), and yyjson_write_number().

◆ YYJSON_WRITE_FP_PREC_BITS

#define YYJSON_WRITE_FP_PREC_BITS   4

The highest 4 bits of flag are reserved for precision value.

Definition at line 1289 of file yyjson.h.

Referenced by write_num(), and yyjson_write_number().

◆ YYJSON_WRITE_FP_TO_FIXED

#define YYJSON_WRITE_FP_TO_FIXED ( prec)
Value:
(uint32_t)((uint32_t)(prec)) << (32 - 4) ))
uint32_t yyjson_write_flag
Definition yyjson.h:1238

Write floating-point number using fixed-point notation.

  • This is similar to ECMAScript Number.prototype.toFixed(prec), but with trailing zeros removed. The prec ranges from 1 to 15.
  • This will produce shorter output but may lose some precision.

Definition at line 1295 of file yyjson.h.

◆ YYJSON_WRITE_FP_TO_FLOAT

#define YYJSON_WRITE_FP_TO_FLOAT   ((yyjson_write_flag)(1 << (32 - 5)))

Write floating-point numbers using single-precision (float).

  • This casts double to float before serialization.
  • This will produce shorter output, but may lose some precision.
  • This flag is ignored if YYJSON_WRITE_FP_TO_FIXED(prec) is also used.

Definition at line 1302 of file yyjson.h.

Referenced by write_num(), and yyjson_write_number().

Typedef Documentation

◆ yyjson_alc

typedef struct yyjson_alc yyjson_alc

A memory allocator.

Typically you don't need to use it, unless you want to customize your own memory allocator.

◆ yyjson_arr_iter

typedef struct yyjson_arr_iter yyjson_arr_iter

A JSON array iterator.

Example

while ((val = yyjson_arr_iter_next(&iter))) {
your_func(val);
}
yyjson_api_inline yyjson_val * yyjson_arr_iter_next(yyjson_arr_iter *iter)
Definition yyjson.h:5672
yyjson_api_inline yyjson_arr_iter yyjson_arr_iter_with(const yyjson_val *arr)
Definition yyjson.h:5662

◆ yyjson_doc

typedef struct yyjson_doc 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.

Definition at line 769 of file yyjson.h.

◆ yyjson_incr_state

typedef struct yyjson_incr_state yyjson_incr_state

Opaque state for incremental JSON reader.

Definition at line 1079 of file yyjson.h.

◆ yyjson_mut_arr_iter

typedef struct yyjson_mut_arr_iter 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

while ((val = yyjson_mut_arr_iter_next(&iter))) {
your_func(val);
if (your_val_is_unused(val)) {
}
}
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_iter_remove(yyjson_mut_arr_iter *iter)
Definition yyjson.h:6387
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_iter_next(yyjson_mut_arr_iter *iter)
Definition yyjson.h:6375
yyjson_api_inline yyjson_mut_arr_iter yyjson_mut_arr_iter_with(yyjson_mut_val *arr)
Definition yyjson.h:6364

◆ yyjson_mut_doc

typedef struct yyjson_mut_doc 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.

Definition at line 783 of file yyjson.h.

◆ yyjson_mut_obj_iter

typedef struct yyjson_mut_obj_iter 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;
while ((key = yyjson_mut_obj_iter_next(&iter))) {
your_func(key, val);
if (your_val_is_unused(key, val)) {
}
}
yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_next(yyjson_mut_obj_iter *iter)
Definition yyjson.h:7020
yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_remove(yyjson_mut_obj_iter *iter)
Definition yyjson.h:7037
yyjson_api_inline yyjson_mut_val * yyjson_mut_obj_iter_get_val(yyjson_mut_val *key)
Definition yyjson.h:7032
yyjson_api_inline yyjson_mut_obj_iter yyjson_mut_obj_iter_with(yyjson_mut_val *obj)
Definition yyjson.h:7009

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_api_inline yyjson_mut_val * yyjson_mut_obj_iter_get(yyjson_mut_obj_iter *iter, const char *key)
Definition yyjson.h:7054
See also
yyjson_mut_obj_iter_get() and yyjson_mut_obj_iter_getn()

◆ yyjson_mut_val

typedef struct yyjson_mut_val yyjson_mut_val

A mutable value for building JSON. A JSON Value has the same lifetime as its document. The memory is held by its document and cannot be freed alone.

Definition at line 790 of file yyjson.h.

◆ yyjson_obj_iter

typedef struct yyjson_obj_iter yyjson_obj_iter

A JSON object iterator.

Example

yyjson_val *key, *val;
while ((key = yyjson_obj_iter_next(&iter))) {
your_func(key, val);
}
yyjson_api_inline yyjson_val * yyjson_obj_iter_get_val(yyjson_val *key)
Definition yyjson.h:5751
yyjson_api_inline yyjson_val * yyjson_obj_iter_next(yyjson_obj_iter *iter)
Definition yyjson.h:5741
yyjson_api_inline yyjson_obj_iter yyjson_obj_iter_with(const yyjson_val *obj)
Definition yyjson.h:5731

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_val *v1 = yyjson_obj_iter_get(&iter, "k1");
yyjson_val *v3 = yyjson_obj_iter_get(&iter, "k3");
yyjson_api_inline yyjson_val * yyjson_obj_iter_get(yyjson_obj_iter *iter, const char *key)
Definition yyjson.h:5755
See also
yyjson_obj_iter_get() and yyjson_obj_iter_getn()

◆ yyjson_patch_code

typedef uint32_t yyjson_patch_code

Result code for JSON patch.

Definition at line 4856 of file yyjson.h.

◆ yyjson_patch_err

typedef struct yyjson_patch_err yyjson_patch_err

Error information for JSON patch.

◆ yyjson_ptr_code

typedef uint32_t yyjson_ptr_code

JSON Pointer error code.

Definition at line 4274 of file yyjson.h.

◆ yyjson_ptr_ctx

typedef struct yyjson_ptr_ctx 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)) {
}
// doc after: {"a":[0,1]}
const char * ptr
Definition yyjson.h:8356
yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_getx(const yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
Definition yyjson.h:7708
yyjson_api_inline bool yyjson_ptr_ctx_remove(yyjson_ptr_ctx *ctx)
Definition yyjson.h:8212
yyjson_api_inline bool yyjson_is_null(const yyjson_val *val)
Definition yyjson.h:5354

◆ yyjson_ptr_err

typedef struct yyjson_ptr_err yyjson_ptr_err

Error information for JSON pointer.

◆ yyjson_read_code

typedef uint32_t yyjson_read_code

Result code for JSON reader.

Definition at line 907 of file yyjson.h.

◆ yyjson_read_err

typedef struct yyjson_read_err yyjson_read_err

Error information for JSON reader.

◆ yyjson_read_flag

typedef uint32_t yyjson_read_flag

Run-time options for JSON reader.

Definition at line 799 of file yyjson.h.

◆ yyjson_str_chunk

typedef struct yyjson_str_chunk yyjson_str_chunk

A memory chunk in string memory pool.

◆ yyjson_str_pool

typedef struct yyjson_str_pool yyjson_str_pool

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

◆ yyjson_subtype

typedef uint8_t yyjson_subtype

Subtype of a JSON value (2 bit).

Definition at line 614 of file yyjson.h.

◆ yyjson_type

typedef uint8_t yyjson_type

Type of a JSON value (3 bit).

Definition at line 595 of file yyjson.h.

◆ yyjson_val

typedef struct yyjson_val yyjson_val

An immutable value for reading JSON. A JSON Value has the same lifetime as its document. The memory is held by its document and cannot be freed alone.

Definition at line 776 of file yyjson.h.

◆ yyjson_val_chunk

typedef struct yyjson_val_chunk yyjson_val_chunk

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

◆ yyjson_val_pool

typedef struct yyjson_val_pool yyjson_val_pool

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

◆ yyjson_val_uni

typedef union yyjson_val_uni yyjson_val_uni

Payload of a JSON value (8 bytes).

◆ yyjson_write_code

typedef uint32_t yyjson_write_code

Result code for JSON writer

Definition at line 1307 of file yyjson.h.

◆ yyjson_write_err

typedef struct yyjson_write_err yyjson_write_err

Error information for JSON writer.

◆ yyjson_write_flag

typedef uint32_t yyjson_write_flag

Run-time options for JSON writer.

Definition at line 1238 of file yyjson.h.

Function Documentation

◆ unsafe_yyjson_arr_is_flat()

yyjson_api_inline bool unsafe_yyjson_arr_is_flat ( const yyjson_val * val)

Definition at line 5136 of file yyjson.h.

Referenced by ptr_arr_get().

◆ unsafe_yyjson_equals()

◆ unsafe_yyjson_equals_str()

yyjson_api_inline bool unsafe_yyjson_equals_str ( const void * val,
const char * str )

Definition at line 5205 of file yyjson.h.

◆ unsafe_yyjson_equals_strn()

yyjson_api_inline bool unsafe_yyjson_equals_strn ( const void * val,
const char * str,
size_t len )

Definition at line 5199 of file yyjson.h.

◆ unsafe_yyjson_get_bool()

yyjson_api_inline bool unsafe_yyjson_get_bool ( const void * val)

◆ unsafe_yyjson_get_first()

yyjson_api_inline yyjson_val * unsafe_yyjson_get_first ( const yyjson_val * ctn)

Definition at line 5187 of file yyjson.h.

Referenced by ptr_arr_get(), ptr_obj_get(), and unsafe_yyjson_equals().

◆ unsafe_yyjson_get_int()

yyjson_api_inline int unsafe_yyjson_get_int ( const void * val)

Definition at line 5159 of file yyjson.h.

◆ unsafe_yyjson_get_len()

◆ unsafe_yyjson_get_next()

yyjson_api_inline yyjson_val * unsafe_yyjson_get_next ( const yyjson_val * val)

Definition at line 5191 of file yyjson.h.

Referenced by ptr_arr_get(), ptr_obj_get(), unsafe_yyjson_equals(), and yyjson_val_mut_copy().

◆ unsafe_yyjson_get_num()

yyjson_api_inline double unsafe_yyjson_get_num ( const void * val)

Definition at line 5167 of file yyjson.h.

◆ unsafe_yyjson_get_raw()

yyjson_api_inline const char * unsafe_yyjson_get_raw ( const void * val)

Definition at line 5142 of file yyjson.h.

◆ unsafe_yyjson_get_real()

yyjson_api_inline double unsafe_yyjson_get_real ( const void * val)

Definition at line 5163 of file yyjson.h.

◆ unsafe_yyjson_get_sint()

yyjson_api_inline int64_t unsafe_yyjson_get_sint ( const void * val)

Definition at line 5155 of file yyjson.h.

◆ unsafe_yyjson_get_str()

◆ unsafe_yyjson_get_subtype()

◆ unsafe_yyjson_get_tag()

yyjson_api_inline uint8_t unsafe_yyjson_get_tag ( const void * val)

Definition at line 5067 of file yyjson.h.

◆ unsafe_yyjson_get_type()

◆ unsafe_yyjson_get_uint()

yyjson_api_inline uint64_t unsafe_yyjson_get_uint ( const void * val)

Definition at line 5151 of file yyjson.h.

◆ unsafe_yyjson_inc_len()

yyjson_api_inline void unsafe_yyjson_inc_len ( void * val)

Definition at line 5232 of file yyjson.h.

◆ unsafe_yyjson_is_arr()

yyjson_api_inline bool unsafe_yyjson_is_arr ( const void * val)

Definition at line 5092 of file yyjson.h.

◆ unsafe_yyjson_is_bool()

yyjson_api_inline bool unsafe_yyjson_is_bool ( const void * val)

Definition at line 5080 of file yyjson.h.

◆ unsafe_yyjson_is_ctn()

yyjson_api_inline bool unsafe_yyjson_is_ctn ( const void * val)

Definition at line 5100 of file yyjson.h.

Referenced by mut_write_root(), and write_root().

◆ unsafe_yyjson_is_false()

yyjson_api_inline bool unsafe_yyjson_is_false ( const void * val)

Definition at line 5131 of file yyjson.h.

◆ unsafe_yyjson_is_int()

yyjson_api_inline bool unsafe_yyjson_is_int ( const void * val)

Definition at line 5115 of file yyjson.h.

◆ unsafe_yyjson_is_null()

yyjson_api_inline bool unsafe_yyjson_is_null ( const void * val)

Definition at line 5076 of file yyjson.h.

Referenced by yyjson_merge_patch(), and yyjson_mut_merge_patch().

◆ unsafe_yyjson_is_num()

yyjson_api_inline bool unsafe_yyjson_is_num ( const void * val)

Definition at line 5084 of file yyjson.h.

◆ unsafe_yyjson_is_obj()

yyjson_api_inline bool unsafe_yyjson_is_obj ( const void * val)

Definition at line 5096 of file yyjson.h.

Referenced by yyjson_mut_patch(), and yyjson_patch().

◆ unsafe_yyjson_is_raw()

yyjson_api_inline bool unsafe_yyjson_is_raw ( const void * val)

Definition at line 5072 of file yyjson.h.

◆ unsafe_yyjson_is_real()

yyjson_api_inline bool unsafe_yyjson_is_real ( const void * val)

Definition at line 5121 of file yyjson.h.

◆ unsafe_yyjson_is_sint()

yyjson_api_inline bool unsafe_yyjson_is_sint ( const void * val)

Definition at line 5110 of file yyjson.h.

◆ unsafe_yyjson_is_str()

yyjson_api_inline bool unsafe_yyjson_is_str ( const void * val)

Definition at line 5088 of file yyjson.h.

◆ unsafe_yyjson_is_str_noesc()

yyjson_api_inline bool unsafe_yyjson_is_str_noesc ( const char * str,
size_t len )

Definition at line 5007 of file yyjson.h.

References len, yyjson_api_inline, and yyjson_constant_p.

◆ unsafe_yyjson_is_true()

yyjson_api_inline bool unsafe_yyjson_is_true ( const void * val)

Definition at line 5126 of file yyjson.h.

◆ unsafe_yyjson_is_uint()

yyjson_api_inline bool unsafe_yyjson_is_uint ( const void * val)

Definition at line 5105 of file yyjson.h.

◆ unsafe_yyjson_mut_equals()

◆ unsafe_yyjson_mut_obj_add()

yyjson_api_inline void unsafe_yyjson_mut_obj_add ( yyjson_mut_val * obj,
yyjson_mut_val * key,
yyjson_mut_val * val,
size_t len )

Definition at line 7174 of file yyjson.h.

Referenced by unsafe_yyjson_mut_ptr_putx().

◆ unsafe_yyjson_mut_obj_remove()

yyjson_api_inline yyjson_mut_val * unsafe_yyjson_mut_obj_remove ( yyjson_mut_val * obj,
const char * key,
size_t key_len )

Definition at line 7191 of file yyjson.h.

◆ unsafe_yyjson_mut_obj_replace()

yyjson_api_inline bool unsafe_yyjson_mut_obj_replace ( yyjson_mut_val * obj,
yyjson_mut_val * key,
yyjson_mut_val * val )

Definition at line 7219 of file yyjson.h.

◆ unsafe_yyjson_mut_obj_rotate()

yyjson_api_inline void unsafe_yyjson_mut_obj_rotate ( yyjson_mut_val * obj,
size_t idx )

Definition at line 7241 of file yyjson.h.

◆ unsafe_yyjson_mut_ptr_getx() [1/2]

◆ unsafe_yyjson_mut_ptr_getx() [2/2]

return unsafe_yyjson_mut_ptr_getx ( val ,
ptr ,
len ,
NULL ,
& err )

◆ unsafe_yyjson_mut_ptr_putx()

◆ unsafe_yyjson_mut_ptr_removex()

◆ unsafe_yyjson_mut_ptr_replacex()

◆ unsafe_yyjson_mut_str_alc()

yyjson_api_inline char * unsafe_yyjson_mut_str_alc ( yyjson_mut_doc * doc,
size_t len )

Definition at line 5866 of file yyjson.h.

Referenced by ptr_new_key().

◆ unsafe_yyjson_mut_strncpy()

yyjson_api_inline char * unsafe_yyjson_mut_strncpy ( yyjson_mut_doc * doc,
const char * str,
size_t len )

Definition at line 5885 of file yyjson.h.

Referenced by unsafe_yyjson_mut_val_mut_copy(), and yyjson_val_mut_copy().

◆ unsafe_yyjson_mut_val()

yyjson_api_inline yyjson_mut_val * unsafe_yyjson_mut_val ( yyjson_mut_doc * doc,
size_t count )

Definition at line 5894 of file yyjson.h.

Referenced by unsafe_yyjson_mut_val_mut_copy(), and yyjson_val_mut_copy().

◆ unsafe_yyjson_ptr_getx() [1/2]

yyjson_api yyjson_val * unsafe_yyjson_ptr_getx ( const yyjson_val * val,
const char * ptr,
size_t len,
yyjson_ptr_err * err )

◆ unsafe_yyjson_ptr_getx() [2/2]

return unsafe_yyjson_ptr_getx ( val ,
ptr ,
len ,
& err )

◆ unsafe_yyjson_set_arr()

yyjson_api_inline void unsafe_yyjson_set_arr ( void * val,
size_t size )

Definition at line 5309 of file yyjson.h.

◆ unsafe_yyjson_set_bool()

yyjson_api_inline void unsafe_yyjson_set_bool ( void * val,
bool num )

Definition at line 5248 of file yyjson.h.

◆ unsafe_yyjson_set_double()

yyjson_api_inline void unsafe_yyjson_set_double ( void * val,
double num )

Definition at line 5280 of file yyjson.h.

◆ unsafe_yyjson_set_float()

yyjson_api_inline void unsafe_yyjson_set_float ( void * val,
float num )

Definition at line 5274 of file yyjson.h.

◆ unsafe_yyjson_set_fp_to_fixed()

yyjson_api_inline void unsafe_yyjson_set_fp_to_fixed ( void * val,
int prec )

Definition at line 5263 of file yyjson.h.

◆ unsafe_yyjson_set_fp_to_float()

yyjson_api_inline void unsafe_yyjson_set_fp_to_float ( void * val,
bool flt )

Definition at line 5268 of file yyjson.h.

◆ unsafe_yyjson_set_len()

yyjson_api_inline void unsafe_yyjson_set_len ( void * val,
size_t len )

Definition at line 5218 of file yyjson.h.

Referenced by unsafe_yyjson_mut_ptr_putx().

◆ unsafe_yyjson_set_null()

yyjson_api_inline void unsafe_yyjson_set_null ( void * val)

Definition at line 5244 of file yyjson.h.

◆ unsafe_yyjson_set_obj()

yyjson_api_inline void unsafe_yyjson_set_obj ( void * val,
size_t size )

Definition at line 5313 of file yyjson.h.

◆ unsafe_yyjson_set_raw()

yyjson_api_inline void unsafe_yyjson_set_raw ( void * val,
const char * raw,
size_t len )

Definition at line 5238 of file yyjson.h.

◆ unsafe_yyjson_set_real()

yyjson_api_inline void unsafe_yyjson_set_real ( void * val,
double num )

Definition at line 5285 of file yyjson.h.

◆ unsafe_yyjson_set_sint()

yyjson_api_inline void unsafe_yyjson_set_sint ( void * val,
int64_t num )

Definition at line 5258 of file yyjson.h.

◆ unsafe_yyjson_set_str()

yyjson_api_inline void unsafe_yyjson_set_str ( void * val,
const char * str )

Definition at line 5301 of file yyjson.h.

◆ unsafe_yyjson_set_str_noesc()

yyjson_api_inline void unsafe_yyjson_set_str_noesc ( void * val,
bool noesc )

Definition at line 5290 of file yyjson.h.

◆ unsafe_yyjson_set_strn()

yyjson_api_inline void unsafe_yyjson_set_strn ( void * val,
const char * str,
size_t len )

Definition at line 5295 of file yyjson.h.

◆ unsafe_yyjson_set_tag()

yyjson_api_inline void unsafe_yyjson_set_tag ( void * val,
yyjson_type type,
yyjson_subtype subtype,
size_t len )

Definition at line 5224 of file yyjson.h.

◆ unsafe_yyjson_set_type()

yyjson_api_inline void unsafe_yyjson_set_type ( void * val,
yyjson_type type,
yyjson_subtype subtype )

Definition at line 5210 of file yyjson.h.

◆ unsafe_yyjson_set_uint()

yyjson_api_inline void unsafe_yyjson_set_uint ( void * val,
uint64_t num )

Definition at line 5253 of file yyjson.h.

◆ unsafe_yyjson_str_pool_grow()

◆ unsafe_yyjson_u64_to_f64()

yyjson_api_inline double unsafe_yyjson_u64_to_f64 ( uint64_t num)

Definition at line 5044 of file yyjson.h.

Referenced by read_num().

◆ unsafe_yyjson_val_pool_grow()

◆ 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
alcThe dynamic allocator to be destroyed.

Definition at line 2540 of file yyjson.c.

References yyjson_alc::ctx, yyjson_alc::free, dyn_ctx::free_list, dyn_chunk::next, unlikely, dyn_ctx::used_list, and YYJSON_DEFAULT_ALC.

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

Definition at line 2524 of file yyjson.c.

References yyjson_alc::ctx, dyn_free(), dyn_malloc(), dyn_realloc(), yyjson_alc::free, yyjson_alc::malloc, yyjson_alc::realloc, unlikely, and YYJSON_DEFAULT_ALC.

◆ 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 document 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
alcThe allocator to be initialized. If alc is NULL, returns false. If buf or size is invalid, this will be set to an empty allocator.
bufThe buffer memory for this allocator. If buf is NULL, returns false.
sizeThe size of buf, in bytes. If size is less than 8 words (32/64 bytes on 32/64-bit OS), returns false.
Returns
true if the alc has been successfully initialized.

Example

// parse JSON with stack memory
char buf[1024];
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_doc * yyjson_read_opts(char *dat, usize len, yyjson_read_flag flg, const yyjson_alc *alc_ptr, yyjson_read_err *err)
Definition yyjson.c:6251
bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, usize size)
Definition yyjson.c:2376
Warning
This Allocator is not thread-safe.

Definition at line 2376 of file yyjson.c.

References yyjson_alc::ctx, yyjson_alc::free, pool_ctx::free_list, yyjson_alc::malloc, mem_align_up(), pool_chunk::next, pool_free(), pool_malloc(), pool_realloc(), yyjson_alc::realloc, pool_chunk::size, pool_ctx::size, size_align_down(), unlikely, and YYJSON_NULL_ALC.

◆ yyjson_arr_get()

yyjson_api_inline yyjson_val * yyjson_arr_get ( const 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.

Definition at line 5603 of file yyjson.h.

Referenced by ensure_media_subtree(), handle_action_route(), handle_state_named_command(), and native_dynamic_dispatch_match().

◆ yyjson_arr_get_first()

yyjson_api_inline yyjson_val * yyjson_arr_get_first ( const yyjson_val * arr)

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

Definition at line 5619 of file yyjson.h.

Referenced by handle_generated_surface_validation_report_command().

◆ yyjson_arr_get_last()

yyjson_api_inline yyjson_val * yyjson_arr_get_last ( const 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.

Definition at line 5628 of file yyjson.h.

◆ 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, returns false.

Definition at line 5668 of file yyjson.h.

◆ yyjson_arr_iter_init()

yyjson_api_inline bool yyjson_arr_iter_init ( const yyjson_val * arr,
yyjson_arr_iter * iter )

Initialize an iterator for this array.

Parameters
arrThe array to be iterated over. If arr is NULL or not an array, iter is cleared.
iterThe iterator to be initialized. If iter is NULL, returns false.
Returns
true if the iter has been successfully initialized.
Note
The iterator does not need to be destroyed.

Definition at line 5650 of file yyjson.h.

Referenced by active_user_id_from_cookie_runtime(), append_generated_admin_surface_rows_runtime(), append_generated_surface_relation_checkboxes_html_runtime(), append_generated_surface_select_options_html_runtime(), append_profile_subscription_rows_runtime(), appointments_render_page_params_json_dup_runtime(), assign_technician_for_slot_runtime(), assign_technician_for_slot_runtime_local(), build_generated_surface_filter_controls_html_runtime(), build_generated_surface_form_fields_html_runtime(), build_generated_surface_sort_options_html_runtime(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), business_open_for_slot_runtime(), business_open_for_slot_runtime_local(), collect_business_service_list_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_active_tenant_ids_lines_runtime(), emit_appointments_page_json_runtime(), emit_business_admin_page_json_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_availability_lines_runtime(), emit_business_calendar_page_json_runtime(), emit_business_calendar_render_page_json_runtime(), emit_business_public_page_json_runtime(), emit_business_public_render_page_json_runtime(), emit_business_technician_ids_lines_runtime(), emit_calendar_page_json_runtime(), emit_explore_page_json_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_profile_render_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_service_assigned_technician_ids_lines_runtime(), emit_service_book_form_page_json_runtime(), emit_sorted_section_lines_runtime(), emit_technician_appointments_lines_runtime(), emit_technician_availability_lines_runtime(), emit_user_appointments_json_runtime(), emit_user_membership_tenant_ids_json_runtime(), explore_render_page_params_json_dup_runtime(), find_active_token_record_runtime(), find_appointment_by_id_runtime_local(), find_array_item_by_long_field_runtime(), find_array_item_by_string_field_runtime(), find_business_by_id_runtime_local(), find_business_by_slug_runtime_local(), find_form_field_value_runtime(), find_service_for_business_runtime_local(), find_user_by_id_runtime_local(), find_user_by_username_runtime_local(), generated_surface_array_contains_string_runtime(), generated_surface_display_value_dup_runtime(), generated_surface_relation_array_all_integers_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_bundle_manifest_layer_for_slice_command(), handle_bundle_manifest_slice_order_command(), handle_file_generated_surface_match_command(), handle_file_migration_backend_list_lines_command(), handle_file_migration_rows_lines_command(), handle_form_field_json_lines_command(), handle_form_options_csv_command(), handle_form_options_html_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_relation_checkboxes_html_command(), handle_generated_surface_select_options_html_command(), handle_generated_surface_submitted_command(), handle_generated_surface_validation_report_command(), handle_object_array_all_integers_command(), handle_object_array_item_json_lines_command(), handle_object_array_lines_command(), handle_object_relative_path_array_to_absolute_json_command(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), handle_state_ucal_import_row_json_lines_command(), handle_validation_field_list_html_command(), handle_validation_summary_text_command(), issue_browser_session_runtime(), json_array_contains_long_runtime(), long_in_array_runtime(), max_id_in_state_section_runtime(), migration_backend_record_runtime(), migration_backend_record_runtime_local(), migration_expected_checksum_dup_runtime(), migration_expected_checksum_dup_runtime_local(), migration_record_by_id_runtime(), native_append_forward_sql_bundle(), native_append_seed_sources_to_buffer(), native_capture_migrate_verify_sqlite_report_json(), native_dynamic_relational_postgresql_runtime_prepare(), native_dynamic_relational_sqlite_runtime_prepare(), native_json_find_object_by_string_field(), native_json_string_array_contains(), native_json_string_array_lines_dup(), native_sqlite_migrate_verify_preflight_ok(), next_array_id_runtime_local(), postgresql_apply_file_list_runtime(), postgresql_apply_file_list_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_task_items_html_dup_runtime(), render_business_dashboard_cards_html_dup_runtime(), render_service_booking_options_editor_html_dup_runtime(), render_service_sort_order_options_html_dup_runtime(), render_technician_checkboxes_html_dup_runtime(), resolve_invite_accept_page_params_json_runtime(), resource_link_display_load_runtime(), service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), sqlite_apply_file_list_runtime(), sqlite_apply_file_list_runtime_local(), state_find_booking_for_user_runtime(), state_find_business_availability_for_business_runtime(), state_find_first_service_for_business_runtime(), state_find_google_calendar_connection_for_business_runtime(), state_find_service_for_business_runtime(), state_find_technician_for_business_runtime(), state_find_user_by_email_runtime(), state_tenant_id_for_business_id_runtime(), state_tenant_id_for_business_runtime_local(), state_tenant_id_for_business_slug_runtime(), surface_build_active_filters_runtime(), surface_build_sort_config_runtime(), surface_filter_item_runtime(), surface_find_by_id_runtime(), surface_find_form_runtime(), surface_find_record_by_string_field_runtime(), technician_booked_for_slot_runtime(), technician_booked_for_slot_runtime_local(), user_has_active_tenant_membership_runtime_local(), user_manages_business_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), and yyjson_patch().

◆ 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, returns NULL.

Definition at line 5672 of file yyjson.h.

Referenced by active_user_id_from_cookie_runtime(), append_generated_admin_surface_rows_runtime(), append_generated_surface_relation_checkboxes_html_runtime(), append_generated_surface_select_options_html_runtime(), append_profile_subscription_rows_runtime(), appointments_render_page_params_json_dup_runtime(), assign_technician_for_slot_runtime(), assign_technician_for_slot_runtime_local(), build_generated_surface_filter_controls_html_runtime(), build_generated_surface_form_fields_html_runtime(), build_generated_surface_sort_options_html_runtime(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), business_open_for_slot_runtime(), business_open_for_slot_runtime_local(), collect_business_service_list_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_active_tenant_ids_lines_runtime(), emit_appointments_page_json_runtime(), emit_business_admin_page_json_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_availability_lines_runtime(), emit_business_calendar_page_json_runtime(), emit_business_calendar_render_page_json_runtime(), emit_business_public_page_json_runtime(), emit_business_public_render_page_json_runtime(), emit_business_technician_ids_lines_runtime(), emit_calendar_page_json_runtime(), emit_explore_page_json_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_profile_render_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_service_assigned_technician_ids_lines_runtime(), emit_service_book_form_page_json_runtime(), emit_sorted_section_lines_runtime(), emit_technician_appointments_lines_runtime(), emit_technician_availability_lines_runtime(), emit_user_appointments_json_runtime(), emit_user_membership_tenant_ids_json_runtime(), explore_render_page_params_json_dup_runtime(), find_active_token_record_runtime(), find_appointment_by_id_runtime_local(), find_array_item_by_long_field_runtime(), find_array_item_by_string_field_runtime(), find_business_by_id_runtime_local(), find_business_by_slug_runtime_local(), find_form_field_value_runtime(), find_service_for_business_runtime_local(), find_user_by_id_runtime_local(), find_user_by_username_runtime_local(), generated_surface_array_contains_string_runtime(), generated_surface_display_value_dup_runtime(), generated_surface_relation_array_all_integers_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_bundle_manifest_layer_for_slice_command(), handle_bundle_manifest_slice_order_command(), handle_file_generated_surface_match_command(), handle_file_migration_backend_list_lines_command(), handle_file_migration_rows_lines_command(), handle_form_field_json_lines_command(), handle_form_options_csv_command(), handle_form_options_html_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_relation_checkboxes_html_command(), handle_generated_surface_select_options_html_command(), handle_generated_surface_submitted_command(), handle_generated_surface_validation_report_command(), handle_object_array_all_integers_command(), handle_object_array_item_json_lines_command(), handle_object_array_lines_command(), handle_object_relative_path_array_to_absolute_json_command(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), handle_state_ucal_import_row_json_lines_command(), handle_validation_field_list_html_command(), handle_validation_summary_text_command(), issue_browser_session_runtime(), json_array_contains_long_runtime(), long_in_array_runtime(), max_id_in_state_section_runtime(), migration_backend_record_runtime(), migration_backend_record_runtime_local(), migration_expected_checksum_dup_runtime(), migration_expected_checksum_dup_runtime_local(), migration_record_by_id_runtime(), native_append_forward_sql_bundle(), native_append_seed_sources_to_buffer(), native_capture_migrate_verify_sqlite_report_json(), native_dynamic_relational_postgresql_runtime_prepare(), native_dynamic_relational_sqlite_runtime_prepare(), native_json_find_object_by_string_field(), native_json_string_array_contains(), native_json_string_array_lines_dup(), native_sqlite_migrate_verify_preflight_ok(), next_array_id_runtime_local(), postgresql_apply_file_list_runtime(), postgresql_apply_file_list_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_task_items_html_dup_runtime(), render_business_dashboard_cards_html_dup_runtime(), render_service_booking_options_editor_html_dup_runtime(), render_service_sort_order_options_html_dup_runtime(), render_technician_checkboxes_html_dup_runtime(), resolve_invite_accept_page_params_json_runtime(), resource_link_display_load_runtime(), service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), sqlite_apply_file_list_runtime(), sqlite_apply_file_list_runtime_local(), state_find_booking_for_user_runtime(), state_find_business_availability_for_business_runtime(), state_find_first_service_for_business_runtime(), state_find_google_calendar_connection_for_business_runtime(), state_find_service_for_business_runtime(), state_find_technician_for_business_runtime(), state_find_user_by_email_runtime(), state_tenant_id_for_business_id_runtime(), state_tenant_id_for_business_runtime_local(), state_tenant_id_for_business_slug_runtime(), surface_build_active_filters_runtime(), surface_build_sort_config_runtime(), surface_filter_item_runtime(), surface_find_by_id_runtime(), surface_find_form_runtime(), surface_find_record_by_string_field_runtime(), technician_booked_for_slot_runtime(), technician_booked_for_slot_runtime_local(), user_has_active_tenant_membership_runtime_local(), user_manages_business_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), and yyjson_patch().

◆ yyjson_arr_iter_with()

yyjson_api_inline yyjson_arr_iter yyjson_arr_iter_with ( const yyjson_val * arr)

Create an iterator with an array, same as yyjson_arr_iter_init().

Parameters
arrThe array to be iterated over. If arr is NULL or not an array, returns an empty iterator.
Returns
A new iterator for the array.
Note
The iterator does not need to be destroyed.

Definition at line 5662 of file yyjson.h.

◆ yyjson_arr_size()

◆ yyjson_deprecated() [1/10]

yyjson_deprecated ( "renamed to unsafe_yyjson_mut_ptr_getx" )

Compatibility alias for unsafe_yyjson_mut_ptr_getx.

◆ yyjson_deprecated() [2/10]

yyjson_deprecated ( "renamed to unsafe_yyjson_ptr_getn" )

Compatibility alias for unsafe_yyjson_ptr_getx.

◆ yyjson_deprecated() [3/10]

yyjson_deprecated ( "renamed to yyjson_doc_ptr_get" )

Compatibility alias for yyjson_doc_ptr_get.

◆ yyjson_deprecated() [4/10]

yyjson_deprecated ( "renamed to yyjson_doc_ptr_getn" )

Compatibility alias for yyjson_doc_ptr_getn.

◆ yyjson_deprecated() [5/10]

yyjson_deprecated ( "renamed to yyjson_mut_doc_ptr_get" )

Compatibility alias for yyjson_mut_doc_ptr_get.

◆ yyjson_deprecated() [6/10]

yyjson_deprecated ( "renamed to yyjson_mut_doc_ptr_getn" )

Compatibility alias for yyjson_mut_doc_ptr_getn.

◆ yyjson_deprecated() [7/10]

yyjson_deprecated ( "renamed to yyjson_mut_ptr_get" )

Compatibility alias for yyjson_mut_ptr_get.

◆ yyjson_deprecated() [8/10]

yyjson_deprecated ( "renamed to yyjson_mut_ptr_getn" )

Compatibility alias for yyjson_mut_ptr_getn.

◆ yyjson_deprecated() [9/10]

yyjson_deprecated ( "renamed to yyjson_ptr_get" )

Compatibility alias for yyjson_ptr_get.

◆ yyjson_deprecated() [10/10]

yyjson_deprecated ( "renamed to yyjson_ptr_getn" )

Compatibility alias for 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.

Definition at line 5335 of file yyjson.h.

Referenced by native_json_doc_free().

◆ yyjson_doc_get_read_size()

yyjson_api_inline size_t yyjson_doc_get_read_size ( const 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.

Definition at line 5327 of file yyjson.h.

◆ yyjson_doc_get_root()

yyjson_api_inline yyjson_val * yyjson_doc_get_root ( const yyjson_doc * doc)

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

Definition at line 5323 of file yyjson.h.

Referenced by active_user_id_from_cookie_runtime(), append_rate_limit_event_runtime_local(), appointments_render_page_params_json_dup_runtime(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_edit_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), ensure_media_subtree(), explore_render_page_params_json_dup_runtime(), generated_admin_manage_page_params_json_dup_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_bundle_manifest_layer_for_slice_command(), handle_bundle_manifest_slice_order_command(), handle_file_compact_object_command(), handle_file_field_number_command(), handle_file_field_string_command(), handle_file_generated_surface_match_command(), handle_file_migration_backend_files_json_command(), handle_file_migration_backend_list_lines_command(), handle_file_migration_backend_record_json_command(), handle_file_migration_rows_lines_command(), handle_file_normalize_ucal_state_command(), handle_file_section_length_command(), handle_form_field_json_command(), handle_form_field_json_lines_command(), handle_form_options_csv_command(), handle_form_options_html_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_edit_page_json_command(), handle_generated_surface_form_fields_html_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_mutate_command(), handle_generated_surface_relation_checkboxes_html_command(), handle_generated_surface_submitted_command(), handle_generated_surface_validation_report_command(), handle_issue_business_invite_action_runtime(), handle_manifest_app_root_command(), handle_manifest_fixture_path_raw_command(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), handle_state_named_command(), handle_template_declared_page_contract_command(), issue_browser_session_runtime(), load_root_from_text_runtime(), native_build_sqlite_migrate_verify_failure_report_json(), native_capture_migrate_verify_sqlite_report_json(), native_dynamic_dispatch_match(), native_dynamic_relational_postgresql_runtime_prepare(), native_dynamic_relational_sqlite_runtime_prepare(), native_sqlite_migrate_verify_preflight_ok(), profile_page_params_json_dup_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_state_root_load_runtime(), resolve_declared_page_params_json_runtime(), resolve_invite_accept_page_params_json_runtime(), resolve_route_fixture_path(), service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), write_business_availability_api_response(), write_business_services_api_response(), and write_generated_surface_schema_response().

◆ yyjson_doc_get_val_count()

yyjson_api_inline size_t yyjson_doc_get_val_count ( const 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.

Definition at line 5331 of file yyjson.h.

◆ yyjson_doc_mut_copy()

◆ yyjson_doc_ptr_get()

yyjson_api_inline yyjson_val * yyjson_doc_ptr_get ( const yyjson_doc * doc,
const char * ptr )

Get value by a JSON Pointer.

Parameters
docThe JSON document to be queried.
ptrThe 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.

Definition at line 7635 of file yyjson.h.

◆ yyjson_doc_ptr_getn()

yyjson_api_inline yyjson_val * yyjson_doc_ptr_getn ( const yyjson_doc * doc,
const char * ptr,
size_t len )

Get value by a JSON Pointer.

Parameters
docThe JSON document to be queried.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe 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.

Definition at line 7641 of file yyjson.h.

◆ yyjson_doc_ptr_getx()

yyjson_api_inline yyjson_val * yyjson_doc_ptr_getx ( const yyjson_doc * doc,
const char * ptr,
size_t len,
yyjson_ptr_err * err )

Get value by a JSON Pointer.

Parameters
docThe JSON document to be queried.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
errA 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.

Definition at line 7646 of file yyjson.h.

◆ yyjson_equals()

yyjson_api_inline bool yyjson_equals ( const yyjson_val * lhs,
const yyjson_val * rhs )

Returns whether two JSON values are equal (deep compare). Returns false if lhs or rhs 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.

Definition at line 5498 of file yyjson.h.

◆ yyjson_equals_str()

◆ yyjson_equals_strn()

yyjson_api_inline bool yyjson_equals_strn ( const yyjson_val * val,
const char * str,
size_t len )

Returns whether the JSON value is equal to a string. The str should be a UTF-8 string, null-terminator is not required. Returns false if val is NULL or type is not string.

Definition at line 5486 of file yyjson.h.

◆ yyjson_get_bool()

◆ yyjson_get_int()

yyjson_api_inline int yyjson_get_int ( const yyjson_val * val)

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

Definition at line 5457 of file yyjson.h.

◆ yyjson_get_len()

◆ yyjson_get_num()

yyjson_api_inline double yyjson_get_num ( const yyjson_val * val)

Returns the content cast to double if the value is a number. Returns 0.0 if val is NULL or type is not number(uint/sint/real).

Definition at line 5465 of file yyjson.h.

◆ yyjson_get_raw()

yyjson_api_inline const char * yyjson_get_raw ( const yyjson_val * val)

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

Definition at line 5441 of file yyjson.h.

◆ yyjson_get_real()

yyjson_api_inline double yyjson_get_real ( const 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).

Definition at line 5461 of file yyjson.h.

Referenced by long_from_value_runtime(), and native_json_long_from_value().

◆ yyjson_get_sint()

yyjson_api_inline int64_t yyjson_get_sint ( const yyjson_val * val)

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

Definition at line 5453 of file yyjson.h.

Referenced by handle_object_path_number_command(), long_from_value_runtime(), long_from_value_runtime_local(), and native_json_long_from_value().

◆ yyjson_get_str()

yyjson_api_inline const char * yyjson_get_str ( const yyjson_val * val)

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

Definition at line 5469 of file yyjson.h.

Referenced by business_dashboard_render_page_params_json_dup_runtime(), default_signed_in_path_runtime(), emit_service_book_form_page_json_runtime(), ensure_media_subtree(), generated_surface_operation_path_dup_runtime(), handle_accept_invite_action_runtime(), handle_file_generated_surface_match_command(), handle_file_migration_backend_list_lines_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_validation_report_command(), handle_manifest_fixture_path_raw_command(), handle_object_array_lines_command(), handle_object_merge_command(), handle_object_path_string_command(), handle_object_relative_path_array_to_absolute_json_command(), json_value_tostring_dup_runtime(), merge_patch_into_mut_object_runtime(), migration_expected_checksum_dup_runtime(), migration_expected_checksum_dup_runtime_local(), native_append_forward_sql_bundle(), native_append_seed_sources_to_buffer(), native_capture_migrate_verify_sqlite_report_json(), native_dynamic_dispatch_match(), native_dynamic_runtime_handle_request(), native_json_string_array_lines_dup(), native_json_string_dup(), native_sqlite_migrate_verify_preflight_ok(), postgresql_apply_file_list_runtime(), postgresql_apply_file_list_runtime_local(), service_book_form_page_params_json_dup_runtime(), sqlite_apply_file_list_runtime(), sqlite_apply_file_list_runtime_local(), template_value_text_dup_runtime(), user_has_active_tenant_membership_runtime_local(), and user_manages_business_runtime().

◆ yyjson_get_subtype()

yyjson_api_inline yyjson_subtype yyjson_get_subtype ( const yyjson_val * val)

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

Definition at line 5416 of file yyjson.h.

◆ yyjson_get_tag()

yyjson_api_inline uint8_t yyjson_get_tag ( const yyjson_val * val)

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

Definition at line 5420 of file yyjson.h.

◆ yyjson_get_type()

yyjson_api_inline yyjson_type yyjson_get_type ( const yyjson_val * val)

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

Definition at line 5412 of file yyjson.h.

◆ yyjson_get_type_desc()

yyjson_api_inline const char * yyjson_get_type_desc ( const 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".

Definition at line 5424 of file yyjson.h.

◆ yyjson_get_uint()

yyjson_api_inline uint64_t yyjson_get_uint ( const yyjson_val * val)

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

Definition at line 5449 of file yyjson.h.

Referenced by long_from_value_runtime(), and native_json_long_from_value().

◆ yyjson_incr_free()

yyjson_api void yyjson_incr_free ( yyjson_incr_state * state)

Release the incremental read state and free the memory.

Definition at line 6613 of file yyjson.c.

References yyjson_incr_state::alc, yyjson_alc::ctx, yyjson_incr_state::flg, yyjson_alc::free, yyjson_incr_state::hdr, yyjson_incr_state::val_hdr, and YYJSON_READ_INSITU.

◆ yyjson_incr_new()

yyjson_api yyjson_incr_state * yyjson_incr_new ( char * buf,
size_t buf_len,
yyjson_read_flag flg,
const yyjson_alc * alc )

Initialize state for incremental read.

To read a large JSON document incrementally:

  1. Call yyjson_incr_new() to create the state for incremental reading.
  2. Call yyjson_incr_read() repeatedly.
  3. Call yyjson_incr_free() to free the state.

Note: The incremental JSON reader only supports standard JSON. Flags for non-standard features (e.g. comments, trailing commas) are ignored.

Parameters
bufThe JSON data, null-terminator is not required. If buf is NULL, returns NULL.
buf_lenThe length of the JSON data in buf. If using YYJSON_READ_INSITU, buf_len should not include the padding size.
flgThe JSON read options. Multiple options can be combined with | operator.
alcThe memory allocator used by JSON reader. Pass NULL to use the libc's default allocator.
Returns
A state for incremental reading. It should be freed with yyjson_incr_free(). NULL is returned if memory allocation fails.

Definition at line 6575 of file yyjson.c.

References yyjson_incr_state::alc, yyjson_incr_state::buf_len, yyjson_alc::ctx, yyjson_incr_state::cur, yyjson_incr_state::flg, yyjson_alc::free, has_flg, yyjson_incr_state::hdr, yyjson_incr_state::label, LABEL_doc_begin, yyjson_alc::malloc, yyjson_incr_state::raw_end, yyjson_incr_state::raw_ptr, unlikely, USIZE_MAX, YYJSON_DEFAULT_ALC, YYJSON_PADDING_SIZE, YYJSON_READ_ALLOW_BOM, YYJSON_READ_ALLOW_INVALID_UNICODE, and YYJSON_READ_JSON5.

◆ yyjson_incr_read()

yyjson_api yyjson_doc * yyjson_incr_read ( yyjson_incr_state * state,
size_t len,
yyjson_read_err * err )

Performs incremental read of up to len bytes.

If NULL is returned and err->code is set to YYJSON_READ_ERROR_MORE, it indicates that more data is required to continue parsing. Then, call this function again with incremented len. Continue until a document is returned or an error other than YYJSON_READ_ERROR_MORE is returned.

Note: Parsing in very small increments is not efficient. An increment of several kilobytes or megabytes is recommended.

Parameters
stateThe state for incremental reading, created using yyjson_incr_new().
lenThe number of bytes of JSON data available to parse. If len is 0, returns NULL.
errA pointer to receive error information.
Returns
A new JSON document, or NULL if an error occurs. When the document is no longer needed, it should be freed with yyjson_doc_free().

Definition at line 6627 of file yyjson.c.

References yyjson_doc::alc, yyjson_incr_state::alc, yyjson_incr_state::alc_len, yyjson_incr_state::buf_len, char_is_ctn(), char_is_num(), char_is_space(), check_maybe_truncated_number, yyjson_read_err::code, yyjson_incr_state::ctn, yyjson_incr_state::ctn_len, yyjson_alc::ctx, yyjson_incr_state::cur, yyjson_doc::dat_read, yyjson_incr_state::flg, has_flg, yyjson_incr_state::hdr, yyjson_incr_state::hdr_len, is_utf16_bom(), is_utf32_bom(), is_utf8_bom(), yyjson_incr_state::label, LABEL_arr_val_begin, LABEL_arr_val_end, LABEL_doc_begin, LABEL_doc_end, LABEL_obj_key_begin, LABEL_obj_key_end, LABEL_obj_val_begin, LABEL_obj_val_end, len, likely, yyjson_alc::malloc, yyjson_read_err::msg, MSG_ARR_END, MSG_CHAR, MSG_CHAR_F, MSG_CHAR_N, MSG_CHAR_T, MSG_COMMA, MSG_DEPTH, MSG_ERR_BOM, MSG_ERR_UTF16, MSG_ERR_UTF32, MSG_GARBAGE, MSG_MALLOC, MSG_NOT_END, MSG_OBJ_END, MSG_OBJ_KEY, MSG_OBJ_SEP, yyjson_val_uni::ofs, yyjson_read_err::pos, yyjson_incr_state::raw_ptr, read_false(), read_null(), read_num(), read_str_con(), read_true(), return_err, return_err_inv_param, yyjson_doc::root, save_incr_state, yyjson_incr_state::str_con, yyjson_doc::str_pool, yyjson_val::tag, yyjson_val::uni, unlikely, USIZE_MAX, yyjson_incr_state::val, yyjson_incr_state::val_end, yyjson_incr_state::val_hdr, val_incr, yyjson_doc::val_read, yyjson_min, YYJSON_READ_ERROR_MORE, YYJSON_READ_ERROR_UNEXPECTED_END, YYJSON_READER_DEPTH_LIMIT, YYJSON_READER_ESTIMATED_MINIFY_RATIO, YYJSON_TAG_BIT, YYJSON_TAG_MASK, YYJSON_TYPE_ARR, YYJSON_TYPE_MASK, and YYJSON_TYPE_OBJ.

◆ yyjson_is_arr()

yyjson_api_inline bool yyjson_is_arr ( const yyjson_val * val)

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

Definition at line 5394 of file yyjson.h.

Referenced by append_generated_surface_relation_checkboxes_html_runtime(), assign_technician_for_slot_runtime(), assign_technician_for_slot_runtime_local(), find_active_token_record_runtime(), find_array_item_by_long_field_runtime(), find_array_item_by_string_field_runtime(), generated_surface_array_contains_string_runtime(), generated_surface_display_value_dup_runtime(), generated_surface_relation_array_all_integers_runtime(), handle_action_route(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_relation_checkboxes_html_command(), handle_generated_surface_validation_report_command(), handle_object_array_all_integers_command(), handle_object_array_item_json_lines_command(), handle_object_array_length_command(), handle_object_array_lines_command(), handle_object_path_array_length_command(), handle_object_relative_path_array_to_absolute_json_command(), handle_state_named_command(), json_array_contains_long_runtime(), long_in_array_runtime(), native_append_seed_sources_to_buffer(), native_json_obj_get_array(), native_json_string_array_contains(), native_json_string_array_lines_dup(), proof_state_root_load_runtime(), proof_task_items_html_dup_runtime(), service_edit_page_params_json_dup_runtime(), state_array_runtime_local(), surface_filter_item_runtime(), write_generated_surface_schema_response(), and yyjson_patch().

◆ yyjson_is_bool()

◆ yyjson_is_ctn()

yyjson_api_inline bool yyjson_is_ctn ( const yyjson_val * val)

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

Definition at line 5402 of file yyjson.h.

◆ yyjson_is_false()

yyjson_api_inline bool yyjson_is_false ( const yyjson_val * val)

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

Definition at line 5362 of file yyjson.h.

◆ yyjson_is_int()

yyjson_api_inline bool yyjson_is_int ( const yyjson_val * val)

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

Definition at line 5378 of file yyjson.h.

Referenced by handle_object_array_all_integers_command(), handle_object_path_number_command(), and long_from_value_runtime_local().

◆ yyjson_is_null()

◆ yyjson_is_num()

yyjson_api_inline bool yyjson_is_num ( const yyjson_val * val)

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

Definition at line 5386 of file yyjson.h.

Referenced by json_value_truthy_runtime(), long_from_value_runtime(), native_json_long_from_value(), and template_value_text_dup_runtime().

◆ yyjson_is_obj()

yyjson_api_inline bool yyjson_is_obj ( const yyjson_val * val)

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

Definition at line 5398 of file yyjson.h.

Referenced by active_user_id_from_cookie_runtime(), append_generated_admin_surface_rows_runtime(), append_generated_surface_relation_checkboxes_html_runtime(), append_generated_surface_select_options_html_runtime(), append_profile_subscription_rows_runtime(), append_validation_error_runtime(), appointments_render_page_params_json_dup_runtime(), assign_technician_for_slot_runtime(), assign_technician_for_slot_runtime_local(), build_generated_surface_filter_controls_html_runtime(), build_generated_surface_form_fields_html_runtime(), build_generated_surface_sort_options_html_runtime(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), business_open_for_slot_runtime(), business_open_for_slot_runtime_local(), collect_business_service_list_runtime(), collect_event_stream_row_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_active_tenant_ids_lines_runtime(), emit_appointments_page_json_runtime(), emit_business_admin_page_json_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_availability_lines_runtime(), emit_business_calendar_page_json_runtime(), emit_business_calendar_render_page_json_runtime(), emit_business_public_page_json_runtime(), emit_business_public_render_page_json_runtime(), emit_business_technician_ids_lines_runtime(), emit_calendar_page_json_runtime(), emit_explore_page_json_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_profile_render_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_service_assigned_technician_ids_lines_runtime(), emit_sorted_section_lines_runtime(), emit_technician_appointments_lines_runtime(), emit_technician_availability_lines_runtime(), emit_user_appointments_json_runtime(), emit_user_membership_tenant_ids_json_runtime(), ensure_media_subtree(), event_stream_allowed_by_scope_runtime(), event_stream_matches_filters_runtime(), event_stream_resource_id_dup_runtime(), explore_render_page_params_json_dup_runtime(), find_active_token_record_runtime(), find_appointment_by_id_runtime_local(), find_array_item_by_long_field_runtime(), find_array_item_by_string_field_runtime(), find_business_by_id_runtime_local(), find_service_for_business_runtime_local(), generated_surface_delete_button_label_dup_runtime(), generated_surface_display_value_dup_runtime(), generated_surface_operation_path_dup_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_file_compact_object_command(), handle_file_field_number_command(), handle_file_field_string_command(), handle_file_generated_surface_match_command(), handle_file_migration_backend_files_json_command(), handle_file_migration_rows_lines_command(), handle_file_normalize_ucal_state_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_display_value_command(), handle_generated_surface_edit_page_json_command(), handle_generated_surface_filter_controls_html_command(), handle_generated_surface_form_fields_html_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_mutate_command(), handle_generated_surface_params_json_command(), handle_generated_surface_relation_checkboxes_html_command(), handle_generated_surface_select_options_html_command(), handle_generated_surface_sort_options_html_command(), handle_generated_surface_submitted_command(), handle_generated_surface_validation_report_command(), handle_object_field_number_command(), handle_object_field_string_command(), handle_object_field_text_command(), handle_object_merge_command(), handle_password_reset_complete_action_runtime(), handle_request_compact_object_command(), handle_request_compact_object_strict_command(), handle_request_field_command(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), handle_state_ucal_import_row_json_lines_command(), handle_template_declared_page_contract_command(), handle_template_render_file_command(), handle_template_render_path_command(), handle_validation_error_envelope_command(), handle_validation_field_list_html_command(), handle_validation_has_errors_command(), handle_validation_summary_text_command(), issue_browser_session_runtime(), max_id_in_state_section_runtime(), merge_patch_into_mut_object_runtime(), migration_expected_checksum_dup_runtime(), migration_expected_checksum_dup_runtime_local(), native_capture_migrate_verify_sqlite_report_json(), native_json_find_object_by_string_field(), native_json_obj_get(), normalized_payload_object_mut_runtime(), object_value_at_path_runtime(), payload_first_long_runtime(), payload_first_string_dup_runtime(), profile_render_page_params_json_dup_runtime(), proof_state_root_load_runtime(), render_business_dashboard_cards_html_dup_runtime(), render_business_fragment_from_doc_dup_runtime(), render_file_template_dup_runtime(), render_service_sort_order_options_html_dup_runtime(), render_technician_checkboxes_html_dup_runtime(), render_template_text_with_default_kind_dup_runtime(), resolve_invite_accept_page_params_json_runtime(), resource_link_display_load_runtime(), service_edit_page_params_json_dup_runtime(), state_find_booking_for_user_runtime(), state_find_business_availability_for_business_runtime(), state_find_first_service_for_business_runtime(), state_find_google_calendar_connection_for_business_runtime(), state_find_service_for_business_runtime(), state_find_technician_for_business_runtime(), state_find_user_by_email_runtime(), state_tenant_id_for_business_id_runtime(), state_tenant_id_for_business_runtime_local(), state_tenant_id_for_business_slug_runtime(), surface_build_sort_config_runtime(), surface_sort_items_runtime(), technician_booked_for_slot_runtime(), technician_booked_for_slot_runtime_local(), user_has_active_tenant_membership_runtime_local(), user_manages_business_runtime(), write_business_availability_api_response(), write_business_services_api_response(), and yyjson_merge_patch().

◆ yyjson_is_raw()

yyjson_api_inline bool yyjson_is_raw ( const yyjson_val * val)

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

Definition at line 5350 of file yyjson.h.

Referenced by yyjson_read_number().

◆ yyjson_is_real()

yyjson_api_inline bool yyjson_is_real ( const yyjson_val * val)

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

Definition at line 5382 of file yyjson.h.

Referenced by handle_object_path_number_command(), long_from_value_runtime(), long_from_value_runtime_local(), and native_json_long_from_value().

◆ yyjson_is_sint()

yyjson_api_inline bool yyjson_is_sint ( const yyjson_val * val)

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

Definition at line 5374 of file yyjson.h.

Referenced by long_from_value_runtime(), and native_json_long_from_value().

◆ yyjson_is_str()

yyjson_api_inline bool yyjson_is_str ( const yyjson_val * val)

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

Definition at line 5390 of file yyjson.h.

Referenced by active_user_id_from_cookie_runtime(), emit_service_book_form_page_json_runtime(), ensure_media_subtree(), find_active_token_record_runtime(), find_array_item_by_string_field_runtime(), find_business_by_slug_runtime_local(), find_user_by_username_runtime_local(), handle_accept_invite_action_runtime(), handle_bundle_manifest_slice_order_command(), handle_file_generated_surface_match_command(), handle_file_migration_backend_list_lines_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_validation_report_command(), handle_manifest_fixture_path_raw_command(), handle_object_array_lines_command(), handle_object_merge_command(), handle_object_path_string_command(), handle_object_relative_path_array_to_absolute_json_command(), handle_password_reset_complete_action_runtime(), handle_request_field_command(), handle_state_named_command(), json_value_tostring_dup_runtime(), merge_patch_into_mut_object_runtime(), migration_backend_record_runtime_local(), migration_expected_checksum_dup_runtime(), migration_expected_checksum_dup_runtime_local(), native_append_forward_sql_bundle(), native_append_seed_sources_to_buffer(), native_capture_migrate_verify_sqlite_report_json(), native_dynamic_runtime_handle_request(), native_json_find_object_by_string_field(), native_json_string_array_contains(), native_json_string_array_lines_dup(), native_json_string_dup(), native_sqlite_migrate_verify_preflight_ok(), postgresql_apply_file_list_runtime(), postgresql_apply_file_list_runtime_local(), resolve_invite_accept_page_params_json_runtime(), revoke_session_by_cookie_runtime(), service_book_form_page_params_json_dup_runtime(), sqlite_apply_file_list_runtime(), sqlite_apply_file_list_runtime_local(), state_tenant_id_for_business_slug_runtime(), template_value_text_dup_runtime(), write_generated_surface_schema_response(), and yyjson_patch().

◆ yyjson_is_true()

yyjson_api_inline bool yyjson_is_true ( const yyjson_val * val)

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

Definition at line 5358 of file yyjson.h.

◆ yyjson_is_uint()

yyjson_api_inline bool yyjson_is_uint ( const yyjson_val * val)

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

Definition at line 5370 of file yyjson.h.

Referenced by handle_object_array_all_integers_command(), handle_object_path_number_command(), long_from_value_runtime(), long_from_value_runtime_local(), and native_json_long_from_value().

◆ 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
strThe input string.
lenThe byte length of the input string.
posThe byte position within the input string.
lineA pointer to receive the line number, starting from 1.
colA pointer to receive the column number, starting from 1.
chrA 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.

Definition at line 3078 of file yyjson.c.

References is_utf8_bom(), len, and likely.

◆ yyjson_merge_patch()

yyjson_api yyjson_mut_val * yyjson_merge_patch ( yyjson_mut_doc * doc,
const yyjson_val * orig,
const 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.

Definition at line 11284 of file yyjson.c.

References yyjson_mut_val::tag, yyjson_val::tag, yyjson_mut_val::uni, yyjson_val::uni, unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_get_str(), unsafe_yyjson_is_null(), yyjson_is_obj(), yyjson_merge_patch(), yyjson_mut_obj(), yyjson_mut_obj_add(), yyjson_obj_foreach, yyjson_obj_getn(), and yyjson_val_mut_copy().

Referenced by yyjson_merge_patch().

◆ yyjson_mut_arr()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr ( yyjson_mut_doc * doc)

Creates and returns an empty mutable array.

Parameters
docA mutable document, used for memory allocation only.
Returns
The new array. NULL if doc is NULL or allocation fails.

Definition at line 6410 of file yyjson.h.

Referenced by append_rate_limit_event_runtime_local(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_public_page_json_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_user_appointments_json_runtime(), ensure_mut_array_field_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_file_normalize_ucal_state_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_submitted_command(), handle_issue_business_invite_action_runtime(), handle_object_relative_path_array_to_absolute_json_command(), handle_password_reset_request_action_runtime(), handle_request_booking_options_json_from_form_command(), handle_request_lines_to_booking_options_json_command(), issue_browser_session_runtime(), surface_build_active_filters_runtime(), write_business_availability_api_response(), and write_business_services_api_response().

◆ 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
docThe doc is only used for memory allocation.
arrThe 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.

Definition at line 6942 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
valThe bool value to be added.
Returns
Whether the operation was successful.

Definition at line 6832 of file yyjson.h.

◆ yyjson_mut_arr_add_double()

yyjson_api_inline bool yyjson_mut_arr_add_double ( yyjson_mut_doc * doc,
yyjson_mut_val * arr,
double num )

Adds a double value at the end of the array.

Parameters
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
numThe number to be added.
Returns
Whether the operation was successful.

Definition at line 6882 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
Returns
Whether the operation was successful.

Definition at line 6823 of file yyjson.h.

◆ yyjson_mut_arr_add_float()

yyjson_api_inline bool yyjson_mut_arr_add_float ( yyjson_mut_doc * doc,
yyjson_mut_val * arr,
float num )

Adds a float value at the end of the array.

Parameters
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
numThe number to be added.
Returns
Whether the operation was successful.

Definition at line 6872 of file yyjson.h.

◆ 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 an integer value at the end of the array.

Parameters
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
numThe number to be added.
Returns
Whether the operation was successful.

Definition at line 6862 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
Returns
Whether the operation was successful.

Definition at line 6805 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe 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.

Definition at line 6951 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
numThe number to be added.
Returns
Whether the operation was successful.

Definition at line 6892 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
numThe number to be added.
Returns
Whether the operation was successful.

Definition at line 6852 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
strA null-terminated UTF-8 string.
Returns
Whether the operation was successful.
Warning
The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.

Definition at line 6902 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
strA null-terminated UTF-8 string.
Returns
Whether the operation was successful.

Definition at line 6922 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
strA UTF-8 string, null-terminator is not required.
lenThe length of the string, in bytes.
Returns
Whether the operation was successful.
Warning
The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document.

Definition at line 6912 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
strA UTF-8 string, null-terminator is not required.
lenThe length of the string, in bytes.
Returns
Whether the operation was successful.

Definition at line 6932 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
Returns
Whether the operation was successful.

Definition at line 6814 of file yyjson.h.

◆ 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
docThe doc is only used for memory allocation.
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
numThe number to be added.
Returns
Whether the operation was successful.

Definition at line 6842 of file yyjson.h.

◆ 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
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
valThe value to be inserted. Returns false if it is NULL.
Returns
Whether the operation was successful.

Definition at line 6800 of file yyjson.h.

◆ 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
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
valThe value to be inserted. Returns false if it is NULL.
Returns
Whether the operation was successful.

Definition at line 6621 of file yyjson.h.

Referenced by append_rate_limit_event_runtime_local(), append_validation_error_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_public_page_json_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_user_appointments_json_runtime(), generated_surface_append_audit_event_mut_runtime(), generated_surface_report_add_field_error_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_mutate_command(), handle_generated_surface_submitted_command(), handle_issue_business_invite_action_runtime(), handle_object_relative_path_array_to_absolute_json_command(), handle_password_reset_request_action_runtime(), handle_request_booking_options_json_from_form_command(), handle_request_lines_to_booking_options_json_command(), handle_state_named_command(), issue_browser_session_runtime(), surface_build_active_filters_runtime(), unsafe_yyjson_mut_ptr_putx(), write_business_availability_api_response(), and write_business_services_api_response().

◆ yyjson_mut_arr_clear()

yyjson_api_inline bool yyjson_mut_arr_clear ( yyjson_mut_val * arr)

Removes all values in this array.

Parameters
arrThe array from which all of the values are to be removed. Returns false if it is NULL or not an array.
Returns
Whether the operation was successful.

Definition at line 6774 of file yyjson.h.

◆ yyjson_mut_arr_get()

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

Definition at line 6318 of file yyjson.h.

Referenced by handle_accept_invite_action_runtime(), handle_action_route(), handle_password_reset_complete_action_runtime(), and handle_state_named_command().

◆ yyjson_mut_arr_get_first()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_get_first ( const yyjson_mut_val * arr)

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

Definition at line 6328 of file yyjson.h.

◆ yyjson_mut_arr_get_last()

yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_get_last ( const yyjson_mut_val * arr)

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

Definition at line 6336 of file yyjson.h.

◆ 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
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
valThe value to be inserted. Returns false if it is NULL.
idxThe index to which to insert the new value. Returns false if the index is out of range.
Returns
Whether the operation was successful.
Warning
This function takes a linear search time.

Definition at line 6590 of file yyjson.h.

◆ 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, returns false.

Definition at line 6371 of file yyjson.h.

◆ 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
arrThe array to be iterated over. If arr is NULL or not an array, iter is cleared.
iterThe iterator to be initialized. If iter is NULL, returns false.
Returns
true if the iter has been successfully initialized.
Note
The iterator does not need to be destroyed.

Definition at line 6350 of file yyjson.h.

Referenced by yyjson_mut_patch().

◆ 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, returns NULL.

Definition at line 6375 of file yyjson.h.

Referenced by yyjson_mut_patch().

◆ 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, returns NULL.

Definition at line 6387 of file yyjson.h.

◆ 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
arrThe array to be iterated over. If arr is NULL or not an array, returns an empty iterator.
Returns
A new iterator for the array.
Note
The iterator does not need to be destroyed.

Definition at line 6364 of file yyjson.h.

◆ 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
arrThe array to which the value is to be inserted. Returns false if it is NULL or not an array.
valThe value to be inserted. Returns false if it is NULL.
Returns
Whether successful.

Definition at line 6640 of file yyjson.h.

◆ 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
arrThe array from which the value is to be removed. Returns false if it is NULL or not an array.
idxThe 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.

Definition at line 6687 of file yyjson.h.

Referenced by handle_action_route(), handle_generated_surface_mutate_command(), and handle_state_named_command().

◆ 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
arrThe 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.

Definition at line 6711 of file yyjson.h.

◆ 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
arrThe 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.

Definition at line 6730 of file yyjson.h.

◆ 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
arrThe array from which the value is to be removed. Returns false if it is NULL or not an array.
idxThe start index of the range (0 is the first).
lenThe number of items in the range (can be 0).
Returns
Whether the operation was successful.
Warning
This function takes a linear search time.

Definition at line 6752 of file yyjson.h.

◆ 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
arrThe array to which the value is to be replaced. Returns false if it is NULL or not an array.
idxThe index to which to replace the value. Returns false if the index is out of range.
valThe 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.

Definition at line 6659 of file yyjson.h.

◆ 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
arrThe array to be rotated.
idxIndex (or times) to rotate.
Warning
This function takes a linear search time.

Definition at line 6782 of file yyjson.h.

◆ yyjson_mut_arr_size()

yyjson_api_inline size_t yyjson_mut_arr_size ( const yyjson_mut_val * arr)

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

Definition at line 6314 of file yyjson.h.

Referenced by handle_state_named_command().

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of boolean values.
countThe value count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

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

Definition at line 6442 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of double numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const double vals[3] = { -1.0, 0.0, 1.0 };
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_double(yyjson_mut_doc *doc, const double *vals, size_t count)
Definition yyjson.h:6529

Definition at line 6529 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of float numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const float vals[3] = { -1.0f, 0.0f, 1.0f };
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_float(yyjson_mut_doc *doc, const float *vals, size_t count)
Definition yyjson.h:6522

Definition at line 6522 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of real numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const double vals[3] = { 0.1, 0.2, 0.3 };
yyjson_api_inline yyjson_mut_val * yyjson_mut_arr_with_real(yyjson_mut_doc *doc, const double *vals, size_t count)
Definition yyjson.h:6459

Definition at line 6459 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of sint numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const int64_t vals[3] = { -1, 0, 1 };
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:6487

Definition at line 6449 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of int16 numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const int16_t vals[3] = { -1, 0, 1 };
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:6473

Definition at line 6473 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of int32 numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const int32_t vals[3] = { -1, 0, 1 };
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:6480

Definition at line 6480 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of int64 numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const int64_t vals[3] = { -1, 0, 1 };

Definition at line 6487 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of int8 numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const int8_t vals[3] = { -1, 0, 1 };
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:6466

Definition at line 6466 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of UTF-8 null-terminator strings. If vals contains NULL, returns NULL.
countThe number of values in vals. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.
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_api_inline yyjson_mut_val * yyjson_mut_arr_with_str(yyjson_mut_doc *doc, const char **vals, size_t count)
Definition yyjson.h:6536

Definition at line 6536 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of UTF-8 null-terminator strings. If vals contains NULL, returns NULL.
countThe number of values in vals. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

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

Definition at line 6553 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of UTF-8 strings, null-terminator is not required. If vals contains NULL, returns NULL.
lensA C array of string lengths, in bytes.
countThe number of strings in vals. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.
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_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:6544

Definition at line 6544 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of UTF-8 strings, null-terminator is not required. If vals contains NULL, returns NULL.
lensA C array of string lengths, in bytes.
countThe number of strings in vals. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

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

Definition at line 6567 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of uint numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const uint64_t vals[3] = { 0, 1, 0 };
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:6454

Definition at line 6454 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of uint16 numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const uint16_t vals[3] = { 0, 1, 0 };
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:6501

Definition at line 6501 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of uint32 numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const uint32_t vals[3] = { 0, 1, 0 };
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:6508

Definition at line 6508 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of uint64 numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const uint64_t vals[3] = { 0, 1, 0 };
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:6515

Definition at line 6515 of file yyjson.h.

◆ 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
docA mutable document, used for memory allocation only. If doc is NULL, returns NULL.
valsA C array of uint8 numbers.
countThe number count. If this value is 0, an empty array is returned.
Returns
The new array. NULL if arguments are invalid or allocation fails.

Example

const uint8_t vals[3] = { 0, 1, 0 };
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:6494

Definition at line 6494 of file yyjson.h.

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

Definition at line 6236 of file yyjson.h.

Referenced by handle_generated_surface_coerce_candidate_command(), handle_generated_surface_mutate_command(), and handle_state_named_command().

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

Definition at line 2653 of file yyjson.c.

References yyjson_mut_doc::alc, yyjson_alc::ctx, yyjson_alc::free, yyjson_mut_doc::str_pool, unsafe_yyjson_str_pool_release(), unsafe_yyjson_val_pool_release(), and yyjson_mut_doc::val_pool.

Referenced by append_rate_limit_event_runtime_local(), append_validation_error_runtime(), appointments_render_page_params_json_dup_runtime(), build_artifact_local_app_manifest_json(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_edit_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_appointments_page_json_runtime(), emit_business_admin_page_json_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_calendar_render_page_json_runtime(), emit_business_dashboard_page_json_runtime(), emit_business_edit_page_json_runtime(), emit_business_public_page_json_runtime(), emit_business_public_render_page_json_runtime(), emit_calendar_page_json_runtime(), emit_explore_page_json_runtime(), emit_json_string_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_profile_render_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_service_book_form_page_json_runtime(), emit_service_edit_page_json_runtime(), emit_technician_edit_page_json_runtime(), emit_template_page_params_json_runtime(), emit_user_appointments_json_runtime(), explore_render_page_params_json_dup_runtime(), generated_admin_manage_page_params_json_dup_runtime(), generated_surface_operation_path_dup_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_file_generated_surface_match_command(), handle_file_normalize_ucal_state_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_edit_page_json_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_mutate_command(), handle_generated_surface_params_json_command(), handle_generated_surface_submitted_command(), handle_generated_surface_validation_report_command(), handle_issue_business_invite_action_runtime(), handle_object_build_command(), handle_object_merge_command(), handle_object_relative_path_array_to_absolute_json_command(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), handle_request_booking_options_json_from_form_command(), handle_request_lines_to_booking_options_json_command(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), handle_state_ucal_import_row_json_lines_command(), handle_template_declared_page_contract_command(), handle_template_layout_page_html_command(), handle_template_layout_page_json_command(), invite_accept_done_page_params_json_dup_runtime(), invite_accept_page_params_json_dup_runtime(), invite_created_page_params_json_dup_runtime(), issue_browser_session_runtime(), login_page_params_json_dup_runtime(), password_reset_complete_page_params_json_dup_runtime(), password_reset_request_page_params_json_dup_runtime(), password_reset_sent_page_params_json_dup_runtime(), profile_page_params_json_dup_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_home_page_params_json_dup_runtime(), register_page_params_json_dup_runtime(), render_business_admin_empty_state_dup_runtime(), render_business_dashboard_cards_html_dup_runtime(), render_page_html_dup_runtime(), render_service_booking_options_editor_html_dup_runtime(), render_service_sort_order_options_html_dup_runtime(), render_service_visual_html_dup_runtime(), render_technician_checkboxes_html_dup_runtime(), revoke_session_by_cookie_runtime(), service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), yyjson_doc_mut_copy(), and yyjson_mut_doc_mut_copy().

◆ yyjson_mut_doc_get_root()

◆ yyjson_mut_doc_imut_copy()

yyjson_api yyjson_doc * yyjson_mut_doc_imut_copy ( const 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.

Definition at line 2898 of file yyjson.c.

References yyjson_mut_doc::root, and yyjson_mut_val_imut_copy().

◆ yyjson_mut_doc_mut_copy()

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

Definition at line 2695 of file yyjson.c.

References yyjson_mut_doc::root, yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), and yyjson_mut_val_mut_copy().

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

Definition at line 2663 of file yyjson.c.

References yyjson_mut_doc::alc, yyjson_str_pool::chunk_size, yyjson_val_pool::chunk_size, yyjson_str_pool::chunk_size_max, yyjson_val_pool::chunk_size_max, yyjson_alc::ctx, yyjson_alc::malloc, yyjson_mut_doc::str_pool, yyjson_mut_doc::val_pool, YYJSON_DEFAULT_ALC, YYJSON_MUT_DOC_STR_POOL_INIT_SIZE, YYJSON_MUT_DOC_STR_POOL_MAX_SIZE, YYJSON_MUT_DOC_VAL_POOL_INIT_SIZE, and YYJSON_MUT_DOC_VAL_POOL_MAX_SIZE.

Referenced by appointments_render_page_params_json_dup_runtime(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_edit_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_appointments_page_json_runtime(), emit_business_admin_page_json_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_calendar_render_page_json_runtime(), emit_business_dashboard_page_json_runtime(), emit_business_edit_page_json_runtime(), emit_business_public_page_json_runtime(), emit_business_public_render_page_json_runtime(), emit_calendar_page_json_runtime(), emit_explore_page_json_runtime(), emit_json_string_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_profile_render_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_service_book_form_page_json_runtime(), emit_service_edit_page_json_runtime(), emit_technician_edit_page_json_runtime(), emit_template_page_params_json_runtime(), emit_user_appointments_json_runtime(), explore_render_page_params_json_dup_runtime(), generated_admin_manage_page_params_json_dup_runtime(), generated_surface_operation_path_dup_runtime(), handle_action_route(), handle_file_generated_surface_match_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_edit_page_json_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_params_json_command(), handle_generated_surface_submitted_command(), handle_object_build_command(), handle_object_merge_command(), handle_object_relative_path_array_to_absolute_json_command(), handle_request_booking_options_json_from_form_command(), handle_request_lines_to_booking_options_json_command(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), handle_state_ucal_import_row_json_lines_command(), handle_template_declared_page_contract_command(), handle_template_layout_page_html_command(), handle_template_layout_page_json_command(), invite_accept_done_page_params_json_dup_runtime(), invite_accept_page_params_json_dup_runtime(), invite_created_page_params_json_dup_runtime(), login_page_params_json_dup_runtime(), password_reset_complete_page_params_json_dup_runtime(), password_reset_request_page_params_json_dup_runtime(), password_reset_sent_page_params_json_dup_runtime(), profile_page_params_json_dup_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_home_page_params_json_dup_runtime(), register_page_params_json_dup_runtime(), render_business_admin_empty_state_dup_runtime(), render_business_dashboard_cards_html_dup_runtime(), render_page_html_dup_runtime(), render_service_booking_options_editor_html_dup_runtime(), render_service_sort_order_options_html_dup_runtime(), render_service_visual_html_dup_runtime(), render_technician_checkboxes_html_dup_runtime(), service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), yyjson_doc_mut_copy(), and yyjson_mut_doc_mut_copy().

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8 with null-terminator).
new_valThe 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.

Definition at line 7766 of file yyjson.h.

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
new_valThe 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.

Definition at line 7773 of file yyjson.h.

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
new_valThe value to be added.
create_parentWhether to create parent nodes if they do not exist.
ctxA pointer to store the result context, or NULL if not needed.
errA 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.

Definition at line 7780 of file yyjson.h.

◆ yyjson_mut_doc_ptr_get()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_get ( const yyjson_mut_doc * doc,
const char * ptr )

Get value by a JSON Pointer.

Parameters
docThe JSON document to be queried.
ptrThe 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.

Definition at line 7697 of file yyjson.h.

◆ yyjson_mut_doc_ptr_getn()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_getn ( const yyjson_mut_doc * doc,
const char * ptr,
size_t len )

Get value by a JSON Pointer.

Parameters
docThe JSON document to be queried.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe 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.

Definition at line 7703 of file yyjson.h.

◆ yyjson_mut_doc_ptr_getx()

yyjson_api_inline yyjson_mut_val * yyjson_mut_doc_ptr_getx ( const 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
docThe JSON document to be queried.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
ctxA pointer to store the result context, or NULL if not needed.
errA 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.

Definition at line 7708 of file yyjson.h.

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8 with null-terminator).
Returns
The removed value, or NULL on error.

Definition at line 8052 of file yyjson.h.

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
Returns
The removed value, or NULL on error.

Definition at line 8058 of file yyjson.h.

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
ctxA pointer to store the result context, or NULL if not needed.
errA pointer to store the error information, or NULL if not needed.
Returns
The removed value, or NULL on error.

Definition at line 8063 of file yyjson.h.

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8 with null-terminator).
new_valThe new value to replace the old one.
Returns
The old value that was replaced, or NULL if not found.

Definition at line 7975 of file yyjson.h.

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
new_valThe new value to replace the old one.
Returns
The old value that was replaced, or NULL if not found.

Definition at line 7981 of file yyjson.h.

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
new_valThe new value to replace the old one.
ctxA pointer to store the result context, or NULL if not needed.
errA pointer to store the error information, or NULL if not needed.
Returns
The old value that was replaced, or NULL if not found.

Definition at line 7986 of file yyjson.h.

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8 with null-terminator).
new_valThe 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.

Definition at line 7868 of file yyjson.h.

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
new_valThe 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.

Definition at line 7875 of file yyjson.h.

◆ 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
docThe target JSON document.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
new_valThe value to be set, pass NULL to remove.
create_parentWhether to create parent nodes if they do not exist.
ctxA pointer to store the result context, or NULL if not needed.
errA 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.

Definition at line 7881 of file yyjson.h.

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

Definition at line 5919 of file yyjson.h.

Referenced by appointments_render_page_params_json_dup_runtime(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_edit_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_appointments_page_json_runtime(), emit_business_admin_page_json_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_calendar_render_page_json_runtime(), emit_business_dashboard_page_json_runtime(), emit_business_edit_page_json_runtime(), emit_business_public_page_json_runtime(), emit_business_public_render_page_json_runtime(), emit_calendar_page_json_runtime(), emit_explore_page_json_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_profile_render_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_service_book_form_page_json_runtime(), emit_service_edit_page_json_runtime(), emit_technician_edit_page_json_runtime(), emit_template_page_params_json_runtime(), emit_user_appointments_json_runtime(), explore_render_page_params_json_dup_runtime(), generated_admin_manage_page_params_json_dup_runtime(), generated_surface_operation_path_dup_runtime(), handle_action_route(), handle_file_generated_surface_match_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_edit_page_json_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_params_json_command(), handle_generated_surface_submitted_command(), handle_generated_surface_validation_report_command(), handle_object_build_command(), handle_object_merge_command(), handle_object_relative_path_array_to_absolute_json_command(), handle_request_booking_options_json_from_form_command(), handle_request_lines_to_booking_options_json_command(), handle_state_event_stream_row_json_lines_command(), handle_template_layout_page_html_command(), handle_template_layout_page_json_command(), login_page_params_json_dup_runtime(), profile_page_params_json_dup_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_home_page_params_json_dup_runtime(), register_page_params_json_dup_runtime(), render_business_admin_empty_state_dup_runtime(), render_business_dashboard_cards_html_dup_runtime(), render_page_html_dup_runtime(), render_service_booking_options_editor_html_dup_runtime(), render_service_sort_order_options_html_dup_runtime(), render_service_visual_html_dup_runtime(), render_technician_checkboxes_html_dup_runtime(), runtime_page_params_write_runtime(), service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), yyjson_doc_mut_copy(), and yyjson_mut_doc_mut_copy().

◆ 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
docThe mutable document.
lenThe desired string pool size in bytes (total string length).
Returns
true if successful, false if size is 0 or overflow.

Definition at line 2639 of file yyjson.c.

References yyjson_str_pool::chunk_size, len, yyjson_mut_doc::str_pool, and USIZE_MAX.

◆ 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
docThe mutable document.
countThe desired value pool size (number of yyjson_mut_val).
Returns
true if successful, false if size is 0 or overflow.

Definition at line 2646 of file yyjson.c.

References yyjson_val_pool::chunk_size, USIZE_MAX, and yyjson_mut_doc::val_pool.

◆ yyjson_mut_double()

yyjson_api_inline yyjson_mut_val * yyjson_mut_double ( yyjson_mut_doc * doc,
double num )

Creates and returns a double number value, returns NULL on error.

Definition at line 6261 of file yyjson.h.

◆ yyjson_mut_equals()

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

Returns whether two JSON values are equal (deep compare). Returns false if lhs or rhs 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.

Definition at line 6059 of file yyjson.h.

Referenced by yyjson_mut_patch(), and yyjson_patch().

◆ yyjson_mut_equals_str()

yyjson_api_inline bool yyjson_mut_equals_str ( const yyjson_mut_val * val,
const char * str )

Returns whether the JSON value is equal to a string. The str should be a null-terminated UTF-8 string. Returns false if val is NULL or type is not string.

Definition at line 6046 of file yyjson.h.

◆ yyjson_mut_equals_strn()

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

Returns whether the JSON value is equal to a string. The str should be a UTF-8 string, null-terminator is not required. Returns false if val is NULL or type is not string.

Definition at line 6051 of file yyjson.h.

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

Definition at line 6232 of file yyjson.h.

◆ yyjson_mut_float()

yyjson_api_inline yyjson_mut_val * yyjson_mut_float ( yyjson_mut_doc * doc,
float num )

Creates and returns a float number value, returns NULL on error.

Definition at line 6256 of file yyjson.h.

◆ yyjson_mut_get_bool()

yyjson_api_inline bool yyjson_mut_get_bool ( const yyjson_mut_val * val)

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

Definition at line 6014 of file yyjson.h.

◆ yyjson_mut_get_int()

yyjson_api_inline int yyjson_mut_get_int ( const yyjson_mut_val * val)

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

Definition at line 6026 of file yyjson.h.

◆ yyjson_mut_get_len()

yyjson_api_inline size_t yyjson_mut_get_len ( const 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.

Definition at line 6042 of file yyjson.h.

◆ yyjson_mut_get_num()

yyjson_api_inline double yyjson_mut_get_num ( const yyjson_mut_val * val)

Returns the content cast to double if the value is a number. Returns 0.0 if val is NULL or type is not number(uint/sint/real).

Definition at line 6034 of file yyjson.h.

◆ yyjson_mut_get_raw()

yyjson_api_inline const char * yyjson_mut_get_raw ( const yyjson_mut_val * val)

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

Definition at line 6010 of file yyjson.h.

◆ yyjson_mut_get_real()

yyjson_api_inline double yyjson_mut_get_real ( const 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).

Definition at line 6030 of file yyjson.h.

◆ yyjson_mut_get_sint()

yyjson_api_inline int64_t yyjson_mut_get_sint ( const 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).

Definition at line 6022 of file yyjson.h.

◆ yyjson_mut_get_str()

yyjson_api_inline const char * yyjson_mut_get_str ( const yyjson_mut_val * val)

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

Definition at line 6038 of file yyjson.h.

◆ yyjson_mut_get_subtype()

yyjson_api_inline yyjson_subtype yyjson_mut_get_subtype ( const yyjson_mut_val * val)

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

Definition at line 5996 of file yyjson.h.

◆ yyjson_mut_get_tag()

yyjson_api_inline uint8_t yyjson_mut_get_tag ( const yyjson_mut_val * val)

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

Definition at line 6001 of file yyjson.h.

◆ yyjson_mut_get_type()

yyjson_api_inline yyjson_type yyjson_mut_get_type ( const yyjson_mut_val * val)

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

Definition at line 5992 of file yyjson.h.

◆ yyjson_mut_get_type_desc()

yyjson_api_inline const char * yyjson_mut_get_type_desc ( const 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".

Definition at line 6005 of file yyjson.h.

◆ yyjson_mut_get_uint()

yyjson_api_inline uint64_t yyjson_mut_get_uint ( const 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).

Definition at line 6018 of file yyjson.h.

◆ yyjson_mut_int()

◆ yyjson_mut_is_arr()

◆ yyjson_mut_is_bool()

yyjson_api_inline bool yyjson_mut_is_bool ( const yyjson_mut_val * val)

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

Definition at line 5946 of file yyjson.h.

◆ yyjson_mut_is_ctn()

yyjson_api_inline bool yyjson_mut_is_ctn ( const yyjson_mut_val * val)

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

Definition at line 5982 of file yyjson.h.

◆ yyjson_mut_is_false()

yyjson_api_inline bool yyjson_mut_is_false ( const yyjson_mut_val * val)

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

Definition at line 5942 of file yyjson.h.

◆ yyjson_mut_is_int()

yyjson_api_inline bool yyjson_mut_is_int ( const yyjson_mut_val * val)

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

Definition at line 5958 of file yyjson.h.

◆ yyjson_mut_is_null()

yyjson_api_inline bool yyjson_mut_is_null ( const yyjson_mut_val * val)

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

Definition at line 5934 of file yyjson.h.

◆ yyjson_mut_is_num()

yyjson_api_inline bool yyjson_mut_is_num ( const yyjson_mut_val * val)

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

Definition at line 5966 of file yyjson.h.

◆ yyjson_mut_is_obj()

◆ yyjson_mut_is_raw()

yyjson_api_inline bool yyjson_mut_is_raw ( const yyjson_mut_val * val)

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

Definition at line 5930 of file yyjson.h.

◆ yyjson_mut_is_real()

yyjson_api_inline bool yyjson_mut_is_real ( const yyjson_mut_val * val)

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

Definition at line 5962 of file yyjson.h.

◆ yyjson_mut_is_sint()

yyjson_api_inline bool yyjson_mut_is_sint ( const yyjson_mut_val * val)

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

Definition at line 5954 of file yyjson.h.

◆ yyjson_mut_is_str()

yyjson_api_inline bool yyjson_mut_is_str ( const yyjson_mut_val * val)

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

Definition at line 5970 of file yyjson.h.

Referenced by yyjson_mut_patch().

◆ yyjson_mut_is_true()

yyjson_api_inline bool yyjson_mut_is_true ( const yyjson_mut_val * val)

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

Definition at line 5938 of file yyjson.h.

◆ yyjson_mut_is_uint()

yyjson_api_inline bool yyjson_mut_is_uint ( const yyjson_mut_val * val)

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

Definition at line 5950 of file yyjson.h.

◆ yyjson_mut_merge_patch()

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

Definition at line 11336 of file yyjson.c.

References yyjson_mut_val::tag, yyjson_mut_val::uni, unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_get_str(), unsafe_yyjson_is_null(), yyjson_mut_is_obj(), yyjson_mut_merge_patch(), yyjson_mut_obj(), yyjson_mut_obj_add(), yyjson_mut_obj_foreach, yyjson_mut_obj_getn(), and yyjson_mut_val_mut_copy().

Referenced by yyjson_mut_merge_patch().

◆ yyjson_mut_null()

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

Definition at line 7086 of file yyjson.h.

Referenced by append_rate_limit_event_runtime_local(), append_validation_error_runtime(), appointments_render_page_params_json_dup_runtime(), build_artifact_local_app_manifest_json(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_edit_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_appointments_page_json_runtime(), emit_business_admin_page_json_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_calendar_render_page_json_runtime(), emit_business_dashboard_page_json_runtime(), emit_business_edit_page_json_runtime(), emit_business_public_page_json_runtime(), emit_business_public_render_page_json_runtime(), emit_calendar_page_json_runtime(), emit_explore_page_json_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_profile_render_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_service_book_form_page_json_runtime(), emit_service_edit_page_json_runtime(), emit_technician_edit_page_json_runtime(), emit_template_page_params_json_runtime(), emit_user_appointments_json_runtime(), explore_render_page_params_json_dup_runtime(), generated_admin_manage_page_params_json_dup_runtime(), generated_surface_append_audit_event_mut_runtime(), generated_surface_operation_path_dup_runtime(), generated_surface_report_add_field_error_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_file_generated_surface_match_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_edit_page_json_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_params_json_command(), handle_generated_surface_submitted_command(), handle_issue_business_invite_action_runtime(), handle_object_build_command(), handle_password_reset_request_action_runtime(), handle_request_booking_options_json_from_form_command(), handle_request_lines_to_booking_options_json_command(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), handle_state_ucal_import_row_json_lines_command(), handle_template_declared_page_contract_command(), handle_template_layout_page_html_command(), handle_template_layout_page_json_command(), invite_accept_done_page_params_json_dup_runtime(), invite_accept_page_params_json_dup_runtime(), invite_created_page_params_json_dup_runtime(), issue_browser_session_runtime(), login_page_params_json_dup_runtime(), normalized_payload_object_mut_runtime(), password_reset_complete_page_params_json_dup_runtime(), password_reset_request_page_params_json_dup_runtime(), password_reset_sent_page_params_json_dup_runtime(), profile_page_params_json_dup_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_home_page_params_json_dup_runtime(), register_page_params_json_dup_runtime(), render_business_admin_empty_state_dup_runtime(), render_business_dashboard_cards_html_dup_runtime(), render_page_html_dup_runtime(), render_service_booking_options_editor_html_dup_runtime(), render_service_sort_order_options_html_dup_runtime(), render_service_visual_html_dup_runtime(), render_technician_checkboxes_html_dup_runtime(), route_template_match_into_mut_obj_runtime(), service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), surface_build_sort_config_runtime(), unsafe_yyjson_mut_ptr_putx(), write_business_availability_api_response(), write_business_services_api_response(), yyjson_merge_patch(), and yyjson_mut_merge_patch().

◆ 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 duplicate keys in one object.

Parameters
objThe object to which the new key-value pair is to be added.
keyThe key, should be a string which is created by yyjson_mut_str(), yyjson_mut_strn(), yyjson_mut_strcpy() or yyjson_mut_strncpy().
valThe value to add to the object.
Returns
Whether the operation was successful.

Definition at line 7248 of file yyjson.h.

Referenced by handle_state_named_command(), unsafe_yyjson_mut_ptr_putx(), yyjson_merge_patch(), and yyjson_mut_merge_patch().

◆ 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 duplicate keys 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.

Definition at line 7505 of file yyjson.h.

◆ 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 duplicate keys in one object.

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

Definition at line 7404 of file yyjson.h.

Referenced by emit_business_admin_service_rows_json_runtime(), emit_business_public_page_json_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_generated_surface_context_command(), handle_object_build_command(), and handle_state_ucal_import_row_json_lines_command().

◆ yyjson_mut_obj_add_double()

yyjson_api_inline bool yyjson_mut_obj_add_double ( 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 duplicate keys in one object.

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

Definition at line 7439 of file yyjson.h.

◆ 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 duplicate keys in one object.

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

Definition at line 7398 of file yyjson.h.

◆ yyjson_mut_obj_add_float()

yyjson_api_inline bool yyjson_mut_obj_add_float ( yyjson_mut_doc * doc,
yyjson_mut_val * obj,
const char * key,
float val )

Adds a float value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicate keys in one object.

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

Definition at line 7432 of file yyjson.h.

◆ 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 duplicate keys in one object.

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

Definition at line 7425 of file yyjson.h.

Referenced by append_rate_limit_event_runtime_local(), build_artifact_local_app_manifest_json(), business_calendar_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_business_admin_page_json_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_calendar_render_page_json_runtime(), emit_business_public_page_json_runtime(), emit_business_public_render_page_json_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_service_book_form_page_json_runtime(), emit_user_appointments_json_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_generated_surface_context_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_issue_business_invite_action_runtime(), handle_object_build_command(), handle_password_reset_request_action_runtime(), handle_request_booking_options_json_from_form_command(), handle_request_lines_to_booking_options_json_command(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), handle_state_ucal_import_row_json_lines_command(), issue_browser_session_runtime(), render_service_booking_options_editor_html_dup_runtime(), render_service_sort_order_options_html_dup_runtime(), render_technician_checkboxes_html_dup_runtime(), and service_book_form_page_params_json_dup_runtime().

◆ 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 duplicate keys in one object.

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

Definition at line 7386 of file yyjson.h.

Referenced by handle_object_build_command().

◆ 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 duplicate keys 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.

Definition at line 7513 of file yyjson.h.

◆ 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 real value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicate keys in one object.

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

Definition at line 7446 of file yyjson.h.

◆ 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 duplicate keys in one object.

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

Definition at line 7418 of file yyjson.h.

◆ 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 duplicate keys in one object.

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

Definition at line 7453 of file yyjson.h.

◆ 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 duplicate keys in one object.

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

Definition at line 7479 of file yyjson.h.

Referenced by add_json_string_or_null_runtime(), append_rate_limit_event_runtime_local(), append_validation_error_runtime(), appointments_render_page_params_json_dup_runtime(), build_artifact_local_app_manifest_json(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_edit_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_appointments_page_json_runtime(), emit_business_admin_page_json_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_calendar_render_page_json_runtime(), emit_business_dashboard_page_json_runtime(), emit_business_edit_page_json_runtime(), emit_business_public_page_json_runtime(), emit_business_public_render_page_json_runtime(), emit_calendar_page_json_runtime(), emit_explore_page_json_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_profile_render_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_service_book_form_page_json_runtime(), emit_service_edit_page_json_runtime(), emit_technician_edit_page_json_runtime(), emit_template_page_params_json_runtime(), emit_user_appointments_json_runtime(), explore_render_page_params_json_dup_runtime(), generated_admin_manage_page_params_json_dup_runtime(), generated_admin_surface_page_copy_runtime(), generated_surface_append_audit_event_mut_runtime(), generated_surface_operation_path_dup_runtime(), generated_surface_report_add_field_error_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_file_generated_surface_match_command(), handle_file_normalize_ucal_state_command(), handle_generated_surface_context_command(), handle_generated_surface_edit_page_json_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_params_json_command(), handle_generated_surface_submitted_command(), handle_issue_business_invite_action_runtime(), handle_object_build_command(), handle_password_reset_request_action_runtime(), handle_request_booking_options_json_from_form_command(), handle_request_lines_to_booking_options_json_command(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), handle_state_ucal_import_row_json_lines_command(), handle_template_declared_page_contract_command(), handle_template_layout_page_html_command(), handle_template_layout_page_json_command(), issue_browser_session_runtime(), login_page_params_json_dup_runtime(), profile_page_params_json_dup_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_home_page_params_json_dup_runtime(), register_page_params_json_dup_runtime(), render_business_admin_empty_state_dup_runtime(), render_business_dashboard_cards_html_dup_runtime(), render_page_html_dup_runtime(), render_service_booking_options_editor_html_dup_runtime(), render_service_sort_order_options_html_dup_runtime(), render_service_visual_html_dup_runtime(), render_technician_checkboxes_html_dup_runtime(), runtime_page_params_add_escaped_string_runtime(), runtime_page_params_add_string_runtime(), service_book_form_page_params_json_dup_runtime(), and service_edit_page_params_json_dup_runtime().

◆ 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 duplicate keys in one object.

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

Definition at line 7467 of file yyjson.h.

◆ 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 duplicate keys in one object.

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

Definition at line 7492 of file yyjson.h.

◆ 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 duplicate keys in one object.

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

Definition at line 7392 of file yyjson.h.

◆ 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 duplicate keys in one object.

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

Definition at line 7411 of file yyjson.h.

◆ 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 duplicate keys in one object.

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

Definition at line 7521 of file yyjson.h.

Referenced by handle_file_normalize_ucal_state_command().

◆ 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
objThe object from which all of the values are to be removed.
Returns
Whether the operation was successful.

Definition at line 7333 of file yyjson.h.

◆ yyjson_mut_obj_get()

◆ yyjson_mut_obj_getn()

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

Definition at line 6975 of file yyjson.h.

Referenced by yyjson_mut_merge_patch().

◆ 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 duplicate keys in one object.

Parameters
objThe object to which the new key-value pair is to be added.
keyThe key, should be a string which is created by yyjson_mut_str(), yyjson_mut_strn(), yyjson_mut_strcpy() or yyjson_mut_strncpy().
valThe value to add to the object.
idxThe index to which to insert the new pair.
Returns
Whether the operation was successful.

Definition at line 7285 of file yyjson.h.

◆ 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
iterThe object iterator, should not be NULL.
keyThe key, should be a UTF-8 string with null-terminator.
Returns
The value to which the specified key is mapped. NULL if the key is not found or arguments are invalid.
Warning
This function takes a linear search time if the key is not nearby.

Definition at line 7054 of file yyjson.h.

◆ 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, returns NULL.

Definition at line 7032 of file yyjson.h.

◆ 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
iterThe object iterator, should not be NULL.
keyThe key, should be a UTF-8 string, null-terminator is not required.
key_lenThe length of key, in bytes.
Returns
The value to which the specified key is mapped. NULL if the key is not found or arguments are invalid.
Warning
This function takes a linear search time if the key is not nearby.

Definition at line 7059 of file yyjson.h.

Referenced by unsafe_yyjson_mut_equals().

◆ 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, returns false.

Definition at line 7016 of file yyjson.h.

◆ 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
objThe object to be iterated over. If obj is NULL or not an object, iter is cleared.
iterThe iterator to be initialized. If iter is NULL, returns false.
Returns
true if the iter has been successfully initialized.
Note
The iterator does not need to be destroyed.

Definition at line 6995 of file yyjson.h.

Referenced by unsafe_yyjson_mut_equals().

◆ 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, returns NULL.

Definition at line 7020 of file yyjson.h.

◆ 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, returns NULL.

Definition at line 7037 of file yyjson.h.

◆ 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_mut_obj_iter_init().

Parameters
objThe object to be iterated over. If obj is NULL or not an object, returns an empty iterator.
Returns
A new iterator for the object.
Note
The iterator does not need to be destroyed.

Definition at line 7009 of file yyjson.h.

◆ 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 adding.

Parameters
objThe object to which the new key-value pair is to be added.
keyThe key, should be a string which is created by yyjson_mut_str(), yyjson_mut_strn(), yyjson_mut_strcpy() or yyjson_mut_strncpy().
valThe value to add to the object. If this value is null, the behavior is the same as yyjson_mut_obj_remove().
Returns
Whether the operation was successful.

Definition at line 7259 of file yyjson.h.

Referenced by add_json_string_or_null_runtime(), append_rate_limit_event_runtime_local(), build_artifact_local_app_manifest_json(), business_detail_admin_render_page_params_json_dup_runtime(), emit_business_admin_page_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_public_page_json_runtime(), emit_profile_page_json_runtime(), ensure_mut_array_field_runtime(), generated_surface_append_audit_event_mut_runtime(), generated_surface_normalize_order_mut_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_file_generated_surface_match_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_mutate_command(), handle_generated_surface_submitted_command(), handle_issue_business_invite_action_runtime(), handle_object_build_command(), handle_object_merge_command(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), issue_browser_session_runtime(), merge_patch_into_mut_object_runtime(), revoke_session_by_cookie_runtime(), route_template_match_into_mut_obj_runtime(), surface_build_active_filters_runtime(), surface_build_sort_config_runtime(), unsafe_yyjson_mut_ptr_putx(), unsafe_yyjson_mut_ptr_removex(), unsafe_yyjson_mut_ptr_replacex(), write_business_availability_api_response(), and write_business_services_api_response().

◆ 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 pairs from the object with the given key.

Parameters
objThe object from which the key-value pair is to be removed.
keyThe 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.

Definition at line 7307 of file yyjson.h.

◆ 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 pairs from the object with the given key.

Parameters
objThe object from which the key-value pair is to be removed.
keyThe 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.

Definition at line 7316 of file yyjson.h.

Referenced by build_artifact_local_app_manifest_json(), ensure_mut_array_field_runtime(), and handle_state_named_command().

◆ 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 pairs from the object with the given key.

Parameters
objThe object from which the key-value pair is to be removed.
keyThe key, should be a UTF-8 string, null-terminator is not required.
key_lenThe length of the key.
Returns
The first matched value, or NULL if no matched value.
Warning
This function takes a linear search time.

Definition at line 7325 of file yyjson.h.

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

Definition at line 7531 of file yyjson.h.

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

Definition at line 7536 of file yyjson.h.

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

Definition at line 7554 of file yyjson.h.

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

Definition at line 7563 of file yyjson.h.

◆ 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 does not exist, or the value is NULL, it will fail.

Parameters
objThe object to which the value is to be replaced.
keyThe key, should be a string value.
valThe value to replace into the object.
Returns
Whether the operation was successful.
Warning
This function takes a linear search time.

Definition at line 7341 of file yyjson.h.

◆ 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
objThe object to be rotated.
idxIndex (or times) to rotate.
Returns
Whether the operation was successful.
Warning
This function takes a linear search time.

Definition at line 7351 of file yyjson.h.

◆ yyjson_mut_obj_size()

yyjson_api_inline size_t yyjson_mut_obj_size ( const 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.

Definition at line 6966 of file yyjson.h.

◆ 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. They should be null-terminated UTF-8 strings.

Warning
The input strings are not copied; you should keep them 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_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:7132

Definition at line 7132 of file yyjson.h.

◆ 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. They should be null-terminated UTF-8 strings.

Warning
The input strings are not copied; you should keep them 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_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:7097

Definition at line 7097 of file yyjson.h.

◆ yyjson_mut_patch()

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

Definition at line 11147 of file yyjson.c.

References constcast, PATCH_OP_ADD, PATCH_OP_COPY, patch_op_get(), PATCH_OP_MOVE, PATCH_OP_REMOVE, PATCH_OP_REPLACE, PATCH_OP_TEST, ptr_add, ptr_get, ptr_remove, ptr_replace, return_err, return_err_copy, return_err_key, return_err_val, unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_is_obj(), yyjson_mut_arr_iter_init(), yyjson_mut_arr_iter_next(), yyjson_mut_equals(), yyjson_mut_is_arr(), yyjson_mut_is_str(), yyjson_mut_obj_get(), and yyjson_mut_val_mut_copy().

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8 with null-terminator).
docOnly used to create new values when needed.
new_valThe 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.

Definition at line 7827 of file yyjson.h.

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
docOnly used to create new values when needed.
new_valThe 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.

Definition at line 7835 of file yyjson.h.

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
docOnly used to create new values when needed.
new_valThe value to be added.
create_parentWhether to create parent nodes if they do not exist.
ctxA pointer to store the result context, or NULL if not needed.
errA 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.

Definition at line 7842 of file yyjson.h.

◆ yyjson_mut_ptr_get()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_get ( const yyjson_mut_val * val,
const char * ptr )

Get value by a JSON Pointer.

Parameters
valThe JSON value to be queried.
ptrThe 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.

Definition at line 7732 of file yyjson.h.

◆ yyjson_mut_ptr_getn()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_getn ( const yyjson_mut_val * val,
const char * ptr,
size_t len )

Get value by a JSON Pointer.

Parameters
valThe JSON value to be queried.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe 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.

Definition at line 7738 of file yyjson.h.

◆ yyjson_mut_ptr_getx()

yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_getx ( const 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
valThe JSON value to be queried.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
ctxA pointer to store the result context, or NULL if not needed.
errA 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.

Definition at line 7744 of file yyjson.h.

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8 with null-terminator).
Returns
The removed value, or NULL on error.

Definition at line 8091 of file yyjson.h.

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
Returns
The removed value, or NULL on error.

Definition at line 8097 of file yyjson.h.

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
ctxA pointer to store the result context, or NULL if not needed.
errA pointer to store the error information, or NULL if not needed.
Returns
The removed value, or NULL on error.

Definition at line 8103 of file yyjson.h.

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8 with null-terminator).
new_valThe new value to replace the old one.
Returns
The old value that was replaced, or NULL if not found.

Definition at line 8019 of file yyjson.h.

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
new_valThe new value to replace the old one.
Returns
The old value that was replaced, or NULL if not found.

Definition at line 8025 of file yyjson.h.

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
new_valThe new value to replace the old one.
ctxA pointer to store the result context, or NULL if not needed.
errA pointer to store the error information, or NULL if not needed.
Returns
The old value that was replaced, or NULL if not found.

Definition at line 8030 of file yyjson.h.

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8 with null-terminator).
new_valThe value to be set, pass NULL to remove.
docOnly 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.

Definition at line 7931 of file yyjson.h.

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
new_valThe value to be set, pass NULL to remove.
docOnly 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.

Definition at line 7939 of file yyjson.h.

◆ 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
valThe target JSON value.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
new_valThe value to be set, pass NULL to remove.
docOnly used to create new values when needed.
create_parentWhether to create parent nodes if they do not exist.
ctxA pointer to store the result context, or NULL if not needed.
errA 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.

Definition at line 7946 of file yyjson.h.

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

Definition at line 6193 of file yyjson.h.

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

Definition at line 6204 of file yyjson.h.

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

Definition at line 6198 of file yyjson.h.

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

Definition at line 6214 of file yyjson.h.

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

◆ yyjson_mut_real()

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

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

Definition at line 6266 of file yyjson.h.

◆ yyjson_mut_set_arr()

yyjson_api_inline bool yyjson_mut_set_arr ( yyjson_mut_val * val)

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

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

Definition at line 6155 of file yyjson.h.

◆ 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 val is NULL.

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

Definition at line 6078 of file yyjson.h.

◆ yyjson_mut_set_double()

yyjson_api_inline bool yyjson_mut_set_double ( yyjson_mut_val * val,
double num )

Set the value to double. Returns false if val is NULL.

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

Definition at line 6108 of file yyjson.h.

◆ yyjson_mut_set_float()

yyjson_api_inline bool yyjson_mut_set_float ( yyjson_mut_val * val,
float num )

Set the value to float. Returns false if val is NULL.

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

Definition at line 6102 of file yyjson.h.

◆ yyjson_mut_set_fp_to_fixed()

yyjson_api_inline bool yyjson_mut_set_fp_to_fixed ( yyjson_mut_val * val,
int prec )

Set the floating-point number's output format to fixed-point notation. Returns false if val is NULL or is not real type.

See also
YYJSON_WRITE_FP_TO_FIXED flag.
Warning
This will modify the mutable value, use with caution.

Definition at line 6120 of file yyjson.h.

◆ yyjson_mut_set_fp_to_float()

yyjson_api_inline bool yyjson_mut_set_fp_to_float ( yyjson_mut_val * val,
bool flt )

Set the floating-point number's output format to single-precision. Returns false if val is NULL or is not real type.

See also
YYJSON_WRITE_FP_TO_FLOAT flag.
Warning
This will modify the mutable value, use with caution.

Definition at line 6127 of file yyjson.h.

◆ yyjson_mut_set_int()

yyjson_api_inline bool yyjson_mut_set_int ( yyjson_mut_val * val,
int64_t num )

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

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

Definition at line 6096 of file yyjson.h.

◆ yyjson_mut_set_null()

yyjson_api_inline bool yyjson_mut_set_null ( yyjson_mut_val * val)

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

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

Definition at line 6072 of file yyjson.h.

◆ yyjson_mut_set_obj()

yyjson_api_inline bool yyjson_mut_set_obj ( yyjson_mut_val * val)

Set the value to object. Returns false if val is NULL.

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

Definition at line 6161 of file yyjson.h.

◆ 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 val is NULL.

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

Definition at line 6065 of file yyjson.h.

◆ 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 val is NULL.

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

Definition at line 6114 of file yyjson.h.

◆ 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 val is NULL.

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

Definition at line 6090 of file yyjson.h.

◆ 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 val is NULL.

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

Definition at line 6134 of file yyjson.h.

◆ yyjson_mut_set_str_noesc()

yyjson_api_inline bool yyjson_mut_set_str_noesc ( yyjson_mut_val * val,
bool noesc )

Marks this string as not needing to be escaped during JSON writing. This can be used to avoid the overhead of escaping if the string contains only characters that do not require escaping. Returns false if val is NULL or is not string.

See also
YYJSON_SUBTYPE_NOESC subtype.
Warning
This will modify the mutable value, use with caution.

Definition at line 6148 of file yyjson.h.

◆ 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 val is NULL.

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

Definition at line 6141 of file yyjson.h.

◆ 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 val is NULL.

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

Definition at line 6084 of file yyjson.h.

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

Definition at line 6246 of file yyjson.h.

Referenced by handle_action_route().

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

Definition at line 6271 of file yyjson.h.

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

Definition at line 6282 of file yyjson.h.

Referenced by add_json_string_or_null_runtime(), append_rate_limit_event_runtime_local(), build_artifact_local_app_manifest_json(), business_detail_admin_render_page_params_json_dup_runtime(), emit_business_admin_page_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_public_page_json_runtime(), emit_json_string_runtime(), emit_profile_page_json_runtime(), ensure_mut_array_field_runtime(), generated_surface_append_audit_event_mut_runtime(), generated_surface_normalize_order_mut_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_file_generated_surface_match_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_mutate_command(), handle_generated_surface_submitted_command(), handle_issue_business_invite_action_runtime(), handle_object_build_command(), handle_object_merge_command(), handle_object_relative_path_array_to_absolute_json_command(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), issue_browser_session_runtime(), merge_patch_into_mut_object_runtime(), revoke_session_by_cookie_runtime(), route_template_match_into_mut_obj_runtime(), surface_build_active_filters_runtime(), surface_build_sort_config_runtime(), write_business_availability_api_response(), and write_business_services_api_response().

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

Definition at line 6276 of file yyjson.h.

Referenced by ptr_new_key().

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

Definition at line 6295 of file yyjson.h.

Referenced by handle_object_relative_path_array_to_absolute_json_command(), and ptr_new_key().

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

Definition at line 6228 of file yyjson.h.

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

Definition at line 6241 of file yyjson.h.

◆ yyjson_mut_val_imut_copy()

yyjson_api yyjson_doc * yyjson_mut_val_imut_copy ( const 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.

Definition at line 2904 of file yyjson.c.

References yyjson_doc::alc, yyjson_alc::ctx, yyjson_doc::dat_read, yyjson_alc::free, yyjson_alc::malloc, yyjson_doc::root, size_align_up(), yyjson_doc::str_pool, yyjson_doc::val_read, YYJSON_DEFAULT_ALC, yyjson_imut_copy(), and yyjson_mut_stat().

Referenced by yyjson_mut_doc_imut_copy().

◆ yyjson_mut_val_mut_copy()

yyjson_api yyjson_mut_val * yyjson_mut_val_mut_copy ( yyjson_mut_doc * doc,
const 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 is managed by the 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.

Definition at line 2826 of file yyjson.c.

References unsafe_yyjson_mut_val_mut_copy().

Referenced by yyjson_mut_doc_mut_copy(), yyjson_mut_merge_patch(), yyjson_mut_patch(), and yyjson_patch().

◆ 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
valThe JSON root value. If val is NULL, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
lenA 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().

Definition at line 1869 of file yyjson.h.

References len, yyjson_api_inline, and yyjson_mut_val_write_opts().

Referenced by emit_compact_json_mut_value_runtime(), emit_json_string_runtime(), handle_generated_surface_default_candidate_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), and handle_state_named_command().

◆ yyjson_mut_val_write_buf()

yyjson_api size_t yyjson_mut_val_write_buf ( char * buf,
size_t buf_len,
const yyjson_mut_val * val,
yyjson_write_flag flg,
yyjson_write_err * err )

Write a value into a buffer.

This function does not allocate memory, but the buffer must be larger than the final JSON size to allow temporary space. See API.md for details.

Parameters
bufThe output buffer. If buf is NULL, returns 0.
buf_lenThe buffer length. If buf_len is too small, returns 0.
valThe JSON root value. If val is NULL, returns 0.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
The number of bytes written (excluding the null terminator), or 0 on failure.

Definition at line 10365 of file yyjson.c.

References yyjson_write_err::code, yyjson_write_err::msg, mut_write_root(), unlikely, YYJSON_NULL_ALC, and YYJSON_WRITE_ERROR_INVALID_PARAMETER.

Referenced by yyjson_mut_write_buf().

◆ 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
pathThe JSON file's path. This should be a null-terminated string using the system's native encoding. If path is NULL or invalid, returns false. If the file is not empty, its content is discarded.
valThe mutable JSON root value. If val is NULL, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA 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.

Definition at line 10389 of file yyjson.c.

References yyjson_write_err::code, constcast, yyjson_alc::ctx, yyjson_alc::free, yyjson_write_err::msg, unlikely, write_dat_to_file(), YYJSON_DEFAULT_ALC, yyjson_mut_val_write_opts(), and YYJSON_WRITE_ERROR_INVALID_PARAMETER.

Referenced by yyjson_mut_write_file().

◆ 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 file pointer with options.

Parameters
fpThe file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false.
valThe mutable JSON root value. If val is NULL, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA 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.

Definition at line 10415 of file yyjson.c.

References yyjson_write_err::code, constcast, yyjson_alc::ctx, yyjson_alc::free, yyjson_write_err::msg, unlikely, write_dat_to_fp(), YYJSON_DEFAULT_ALC, yyjson_mut_val_write_opts(), and YYJSON_WRITE_ERROR_INVALID_PARAMETER.

Referenced by yyjson_mut_write_fp().

◆ 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
valThe mutable JSON root value. If val is NULL, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
lenA pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information.
errA 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().

Definition at line 10339 of file yyjson.c.

References mut_write_root().

Referenced by yyjson_mut_val_write(), yyjson_mut_val_write_file(), and yyjson_mut_val_write_fp().

◆ 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
docThe JSON document. If doc is NULL or has no root, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
lenA 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().

Definition at line 1604 of file yyjson.h.

References len, yyjson_api_inline, and yyjson_mut_write_opts().

Referenced by append_rate_limit_event_runtime_local(), appointments_render_page_params_json_dup_runtime(), build_artifact_local_app_manifest_json(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_edit_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_compact_mutable_json_doc_runtime(), explore_render_page_params_json_dup_runtime(), generated_admin_manage_page_params_json_dup_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), handle_template_layout_page_html_command(), issue_browser_session_runtime(), login_page_params_json_dup_runtime(), profile_page_params_json_dup_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_home_page_params_json_dup_runtime(), register_page_params_json_dup_runtime(), render_business_fragment_from_doc_dup_runtime(), render_page_html_dup_runtime(), revoke_session_by_cookie_runtime(), runtime_page_params_write_runtime(), service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), and write_mutable_json_doc_runtime().

◆ yyjson_mut_write_buf()

yyjson_api size_t yyjson_mut_write_buf ( char * buf,
size_t buf_len,
const yyjson_mut_doc * doc,
yyjson_write_flag flg,
yyjson_write_err * err )

Write a document into a buffer.

This function does not allocate memory, but the buffer must be larger than the final JSON size to allow temporary space. See API.md for details.

Parameters
bufThe output buffer. If buf is NULL, returns 0.
buf_lenThe buffer length. If buf_len is too small, returns 0.
docThe JSON document. If doc is NULL or has no root, returns 0.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
The number of bytes written (excluding the null terminator), or 0 on failure.

Definition at line 10379 of file yyjson.c.

References yyjson_mut_doc::root, and yyjson_mut_val_write_buf().

◆ 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
pathThe JSON file's path. This should be a null-terminated string using the system's native encoding. If path is NULL or invalid, returns false. If the file is not empty, its content is discarded.
docThe mutable JSON document. If doc is NULL or has no root, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA 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.

Definition at line 10441 of file yyjson.c.

References yyjson_mut_doc::root, and yyjson_mut_val_write_file().

◆ 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
fpThe file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false.
docThe mutable JSON document. If doc is NULL or has no root, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA 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.

Definition at line 10450 of file yyjson.c.

References yyjson_mut_doc::root, and yyjson_mut_val_write_fp().

◆ yyjson_mut_write_number()

yyjson_api_inline char * yyjson_mut_write_number ( const yyjson_mut_val * val,
char * buf )

Same as yyjson_write_number().

Definition at line 1898 of file yyjson.h.

References yyjson_api_inline, and yyjson_write_number().

◆ 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
docThe mutable JSON document. If doc is NULL or has no root, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
lenA pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information.
errA 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().

Definition at line 10347 of file yyjson.c.

References likely, mut_write_root(), yyjson_mut_doc::root, and yyjson_mut_doc_estimated_val_num().

Referenced by yyjson_mut_write().

◆ yyjson_obj_get()

yyjson_api_inline yyjson_val * yyjson_obj_get ( const 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.

Definition at line 5693 of file yyjson.h.

Referenced by native_json_find_object_by_string_field(), native_json_obj_get(), and yyjson_patch().

◆ yyjson_obj_getn()

yyjson_api_inline yyjson_val * yyjson_obj_getn ( const 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.

Definition at line 5698 of file yyjson.h.

Referenced by yyjson_merge_patch().

◆ 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
iterThe object iterator, should not be NULL.
keyThe key, should be a UTF-8 string with null-terminator.
Returns
The value to which the specified key is mapped. NULL if the key is not found or arguments are invalid.
Warning
This function takes a linear search time if the key is not nearby.

Definition at line 5755 of file yyjson.h.

◆ 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, returns NULL.

Definition at line 5751 of file yyjson.h.

Referenced by handle_file_generated_surface_match_command(), handle_generated_surface_coerce_candidate_command(), handle_object_merge_command(), and merge_patch_into_mut_object_runtime().

◆ 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
iterThe object iterator, should not be NULL.
keyThe key, should be a UTF-8 string, null-terminator is not required.
key_lenThe length of key, in bytes.
Returns
The value to which the specified key is mapped. NULL if the key is not found or arguments are invalid.
Warning
This function takes a linear search time if the key is not nearby.

Definition at line 5760 of file yyjson.h.

Referenced by unsafe_yyjson_equals().

◆ 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, returns false.

Definition at line 5737 of file yyjson.h.

◆ yyjson_obj_iter_init()

yyjson_api_inline bool yyjson_obj_iter_init ( const yyjson_val * obj,
yyjson_obj_iter * iter )

Initialize an iterator for this object.

Parameters
objThe object to be iterated over. If obj is NULL or not an object, iter is cleared.
iterThe iterator to be initialized. If iter is NULL, returns false.
Returns
true if the iter has been successfully initialized.
Note
The iterator does not need to be destroyed.

Definition at line 5718 of file yyjson.h.

Referenced by handle_file_generated_surface_match_command(), handle_generated_surface_coerce_candidate_command(), handle_object_merge_command(), merge_patch_into_mut_object_runtime(), and unsafe_yyjson_equals().

◆ 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, returns NULL.

Definition at line 5741 of file yyjson.h.

Referenced by handle_file_generated_surface_match_command(), handle_generated_surface_coerce_candidate_command(), handle_object_merge_command(), and merge_patch_into_mut_object_runtime().

◆ yyjson_obj_iter_with()

yyjson_api_inline yyjson_obj_iter yyjson_obj_iter_with ( const yyjson_val * obj)

Create an iterator with an object, same as yyjson_obj_iter_init().

Parameters
objThe object to be iterated over. If obj is NULL or not an object, returns an empty iterator.
Returns
A new iterator for the object.
Note
The iterator does not need to be destroyed.

Definition at line 5731 of file yyjson.h.

◆ yyjson_obj_size()

yyjson_api_inline size_t yyjson_obj_size ( const yyjson_val * obj)

Returns the number of key-value pairs in this object. Returns 0 if obj is NULL or type is not object.

Definition at line 5689 of file yyjson.h.

◆ yyjson_patch()

yyjson_api yyjson_mut_val * yyjson_patch ( yyjson_mut_doc * doc,
const yyjson_val * orig,
const 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.

Definition at line 11026 of file yyjson.c.

References PATCH_OP_ADD, PATCH_OP_COPY, patch_op_get(), PATCH_OP_MOVE, PATCH_OP_REMOVE, PATCH_OP_REPLACE, PATCH_OP_TEST, ptr_add, ptr_get, ptr_remove, ptr_replace, return_err, return_err_copy, return_err_key, return_err_val, unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_is_obj(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_is_arr(), yyjson_is_str(), yyjson_mut_equals(), yyjson_mut_val_mut_copy(), yyjson_obj_get(), and yyjson_val_mut_copy().

◆ 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
ctxThe context from the yyjson_mut_ptr_xxx() calls.
keyNew key if ctx->ctn is object, or NULL if ctx->ctn is array.
valNew value to be added.
Returns
true on success or false on fail.

Definition at line 8126 of file yyjson.h.

◆ yyjson_ptr_ctx_remove()

yyjson_api_inline bool yyjson_ptr_ctx_remove ( yyjson_ptr_ctx * ctx)

Remove value by JSON pointer context.

Parameters
ctxThe context from the yyjson_mut_ptr_xxx() calls.
Returns
true on success or false on fail.
Note
On success, the old value will be returned via ctx->old.

Definition at line 8212 of file yyjson.h.

Referenced by unsafe_yyjson_mut_ptr_removex().

◆ 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
ctxThe context from the yyjson_mut_ptr_xxx() calls.
valNew value to be replaced.
Returns
true on success or false on fail.
Note
On success, the old value will be returned via ctx->old.

Definition at line 8180 of file yyjson.h.

Referenced by unsafe_yyjson_mut_ptr_replacex().

◆ yyjson_ptr_get()

yyjson_api_inline yyjson_val * yyjson_ptr_get ( const yyjson_val * val,
const char * ptr )

Get value by a JSON Pointer.

Parameters
valThe JSON value to be queried.
ptrThe 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.

Definition at line 7668 of file yyjson.h.

◆ yyjson_ptr_get_bool()

yyjson_api_inline bool yyjson_ptr_get_bool ( const 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.

Definition at line 8254 of file yyjson.h.

◆ yyjson_ptr_get_num()

yyjson_api_inline bool yyjson_ptr_get_num ( const 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.

Definition at line 8321 of file yyjson.h.

◆ yyjson_ptr_get_real()

yyjson_api_inline bool yyjson_ptr_get_real ( const 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.

Definition at line 8305 of file yyjson.h.

◆ yyjson_ptr_get_sint()

yyjson_api_inline bool yyjson_ptr_get_sint ( const 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.

Definition at line 8287 of file yyjson.h.

◆ yyjson_ptr_get_str()

yyjson_api_inline bool yyjson_ptr_get_str ( const 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.

Definition at line 8336 of file yyjson.h.

◆ yyjson_ptr_get_uint()

yyjson_api_inline bool yyjson_ptr_get_uint ( const 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.

Definition at line 8269 of file yyjson.h.

◆ yyjson_ptr_getn()

yyjson_api_inline yyjson_val * yyjson_ptr_getn ( const yyjson_val * val,
const char * ptr,
size_t len )

Get value by a JSON Pointer.

Parameters
valThe JSON value to be queried.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe 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.

Definition at line 7674 of file yyjson.h.

◆ yyjson_ptr_getx()

yyjson_api_inline yyjson_val * yyjson_ptr_getx ( const yyjson_val * val,
const char * ptr,
size_t len,
yyjson_ptr_err * err )

Get value by a JSON Pointer.

Parameters
valThe JSON value to be queried.
ptrThe JSON pointer string (UTF-8, null-terminator is not required).
lenThe length of ptr in bytes.
errA 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.

Definition at line 7679 of file yyjson.h.

◆ 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
datThe JSON data (UTF-8 without BOM), null-terminator is not required. If dat is NULL, returns NULL.
lenThe length of JSON data in bytes. If len is 0, returns NULL.
flgThe 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().

Definition at line 1066 of file yyjson.h.

References len, yyjson_api_inline, YYJSON_READ_INSITU, and yyjson_read_opts().

Referenced by native_json_doc_load_text().

◆ 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
pathThe JSON file's path. This should be a null-terminated string using the system's native encoding. If path is NULL or invalid, returns NULL.
flgThe JSON read options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON reader. Pass NULL to use the libc's default allocator.
errA 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.

Definition at line 6341 of file yyjson.c.

References fopen_readonly(), MSG_FREAD, return_err, unlikely, and yyjson_read_fp().

◆ 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
fpThe file pointer. The data will be read from the current position of the FILE to the end. If fp is NULL or invalid, returns NULL.
flgThe JSON read options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON reader. Pass NULL to use the libc's default allocator.
errA 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.

Definition at line 6369 of file yyjson.c.

References yyjson_alc::ctx, fread_safe(), yyjson_alc::free, yyjson_alc::malloc, MSG_FREAD, MSG_MALLOC, yyjson_alc::realloc, return_err, yyjson_doc::str_pool, unlikely, YYJSON_DEFAULT_ALC, YYJSON_PADDING_SIZE, YYJSON_READ_INSITU, and yyjson_read_opts().

Referenced by yyjson_read_file().

◆ yyjson_read_max_memory_usage()

yyjson_api_inline size_t yyjson_read_max_memory_usage ( size_t len,
yyjson_read_flag flg )

Returns the maximum memory usage to read a JSON document.

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
lenThe length of JSON data in bytes.
flgThe 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));
// use one allocator for multiple JSON
size_t size = yyjson_read_max_memory_usage(max_len, 0);
void *buf = malloc(size);
yyjson_alc_pool_init(&alc, buf, size);
// no more malloc() or realloc() call during reading
doc = yyjson_read_opts(dat1, len1, 0, &alc, NULL);
doc = yyjson_read_opts(dat2, len2, 0, &alc, NULL);
doc = yyjson_read_opts(dat3, len3, 0, &alc, NULL);
free(buf);
yyjson_api_inline void yyjson_doc_free(yyjson_doc *doc)
Definition yyjson.h:5335
yyjson_api_inline size_t yyjson_read_max_memory_usage(size_t len, yyjson_read_flag flg)
Definition yyjson.h:1173
See also
yyjson_alc_pool_init()

Definition at line 1173 of file yyjson.h.

References yyjson_incr_state::flg, len, yyjson_api_inline, YYJSON_READ_INSITU, and YYJSON_READ_STOP_WHEN_DONE.

◆ 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
datThe JSON data (UTF-8 without BOM), null-terminator is required. If dat is NULL, returns NULL.
valThe output value where result is stored. If val is NULL, returns NULL. The value will hold either UINT or SINT or REAL number;
flgThe 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.
alcThe 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.
errA 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.

Definition at line 6469 of file yyjson.c.

References constcast, yyjson_alc::ctx, yyjson_alc::free, yyjson_alc::malloc, MSG_MALLOC, read_num(), return_err, yyjson_val_uni::str, yyjson_val::uni, unlikely, YYJSON_DEFAULT_ALC, and yyjson_is_raw().

Referenced by yyjson_mut_read_number().

◆ 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
datThe JSON data (UTF-8 without BOM), null-terminator is not required. If dat is NULL, returns NULL. The dat will not be modified without the flag YYJSON_READ_INSITU, so you can pass a const char * string and cast it to char * if you don't use the YYJSON_READ_INSITU flag.
lenThe length of JSON data in bytes. If len is 0, returns NULL.
flgThe JSON read options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON reader. Pass NULL to use the libc's default allocator.
errA 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().

Definition at line 6251 of file yyjson.c.

References char_is_ctn(), char_is_space(), char_is_trivia(), yyjson_read_err::code, yyjson_alc::ctx, yyjson_alc::free, has_allow, has_flg, is_utf16_bom(), is_utf32_bom(), is_utf8_bom(), len, likely, yyjson_alc::malloc, yyjson_read_err::msg, MSG_COMMENT, MSG_ERR_BOM, MSG_ERR_UTF16, MSG_ERR_UTF32, MSG_MALLOC, yyjson_read_err::pos, read_root_minify(), read_root_pretty(), read_root_single(), return_err, skip_trivia(), unlikely, USIZE_MAX, YYJSON_DEFAULT_ALC, YYJSON_PADDING_SIZE, and YYJSON_READ_ERROR_MEMORY_ALLOCATION.

Referenced by yyjson_read(), and yyjson_read_fp().

◆ yyjson_set_bool()

yyjson_api_inline bool yyjson_set_bool ( yyjson_val * val,
bool num )

Set the value to bool. Returns false if val is NULL or is object or array.

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

Definition at line 5518 of file yyjson.h.

◆ yyjson_set_double()

yyjson_api_inline bool yyjson_set_double ( yyjson_val * val,
double num )

Set the value to double. Returns false if val is NULL or is object or array.

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

Definition at line 5548 of file yyjson.h.

◆ yyjson_set_float()

yyjson_api_inline bool yyjson_set_float ( yyjson_val * val,
float num )

Set the value to float. Returns false if val is NULL or is object or array.

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

Definition at line 5542 of file yyjson.h.

◆ yyjson_set_fp_to_fixed()

yyjson_api_inline bool yyjson_set_fp_to_fixed ( yyjson_val * val,
int prec )

Set the floating-point number's output format to fixed-point notation. Returns false if val is NULL or is not real type.

See also
YYJSON_WRITE_FP_TO_FIXED flag.
Warning
This will modify the immutable value, use with caution.

Definition at line 5560 of file yyjson.h.

◆ yyjson_set_fp_to_float()

yyjson_api_inline bool yyjson_set_fp_to_float ( yyjson_val * val,
bool flt )

Set the floating-point number's output format to single-precision. Returns false if val is NULL or is not real type.

See also
YYJSON_WRITE_FP_TO_FLOAT flag.
Warning
This will modify the immutable value, use with caution.

Definition at line 5566 of file yyjson.h.

◆ yyjson_set_int()

yyjson_api_inline bool yyjson_set_int ( yyjson_val * val,
int64_t num )

Set the value to int. Returns false if val is NULL or is object or array.

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

Definition at line 5536 of file yyjson.h.

◆ yyjson_set_null()

yyjson_api_inline bool yyjson_set_null ( yyjson_val * val)

Set the value to null. Returns false if val is NULL or is object or array.

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

Definition at line 5512 of file yyjson.h.

◆ 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 val is NULL or is object or array.

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

Definition at line 5504 of file yyjson.h.

◆ yyjson_set_real()

yyjson_api_inline bool yyjson_set_real ( yyjson_val * val,
double num )

Set the value to real. Returns false if val is NULL or is object or array.

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

Definition at line 5554 of file yyjson.h.

◆ yyjson_set_sint()

yyjson_api_inline bool yyjson_set_sint ( yyjson_val * val,
int64_t num )

Set the value to sint. Returns false if val is NULL or is object or array.

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

Definition at line 5530 of file yyjson.h.

◆ 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 val is NULL or is object or array.

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

Definition at line 5572 of file yyjson.h.

◆ yyjson_set_str_noesc()

yyjson_api_inline bool yyjson_set_str_noesc ( yyjson_val * val,
bool noesc )

Marks this string as not needing to be escaped during JSON writing. This can be used to avoid the overhead of escaping if the string contains only characters that do not require escaping. Returns false if val is NULL or is not string.

See also
YYJSON_SUBTYPE_NOESC subtype.
Warning
This will modify the immutable value, use with caution.

Definition at line 5587 of file yyjson.h.

◆ 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 val is NULL or is object or array.

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

Definition at line 5579 of file yyjson.h.

◆ yyjson_set_uint()

yyjson_api_inline bool yyjson_set_uint ( yyjson_val * val,
uint64_t num )

Set the value to uint. Returns false if val is NULL or is object or array.

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

Definition at line 5524 of file yyjson.h.

◆ yyjson_val_mut_copy()

yyjson_api yyjson_mut_val * yyjson_val_mut_copy ( yyjson_mut_doc * doc,
const 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 is managed by the mutable document.

Note
imut_val -> mut_val.

Definition at line 2714 of file yyjson.c.

References constcast, len, yyjson_mut_val::next, yyjson_val_uni::ptr, yyjson_val_uni::str, yyjson_mut_val::tag, yyjson_val::tag, yyjson_val_uni::u64, yyjson_mut_val::uni, yyjson_val::uni, unsafe_yyjson_get_len(), unsafe_yyjson_get_next(), unsafe_yyjson_get_type(), unsafe_yyjson_mut_strncpy(), unsafe_yyjson_mut_val(), YYJSON_TYPE_ARR, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, and YYJSON_TYPE_STR.

Referenced by generated_surface_append_audit_event_mut_runtime(), handle_action_route(), handle_file_generated_surface_match_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_mutate_command(), handle_generated_surface_submitted_command(), handle_object_build_command(), handle_object_merge_command(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), merge_patch_into_mut_object_runtime(), normalized_payload_object_mut_runtime(), surface_build_active_filters_runtime(), surface_build_sort_config_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), yyjson_doc_mut_copy(), yyjson_merge_patch(), and yyjson_patch().

◆ 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
valThe JSON root value. If val is NULL, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
lenA 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().

Definition at line 1738 of file yyjson.h.

References len, yyjson_api_inline, and yyjson_val_write_opts().

Referenced by native_json_serialize_compact_dup().

◆ yyjson_val_write_buf()

yyjson_api size_t yyjson_val_write_buf ( char * buf,
size_t buf_len,
const yyjson_val * val,
yyjson_write_flag flg,
yyjson_write_err * err )

Write a value into a buffer.

This function does not allocate memory, but the buffer must be larger than the final JSON size to allow temporary space. See API.md for details.

Parameters
bufThe output buffer. If buf is NULL, returns 0.
buf_lenThe buffer length. If buf_len is too small, returns 0.
valThe JSON root value. If val is NULL, returns 0.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
The number of bytes written (excluding the null terminator), or 0 on failure.

Definition at line 9807 of file yyjson.c.

References yyjson_write_err::code, yyjson_write_err::msg, unlikely, write_root(), YYJSON_NULL_ALC, and YYJSON_WRITE_ERROR_INVALID_PARAMETER.

Referenced by yyjson_write_buf().

◆ 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
pathThe JSON file's path. This should be a null-terminated string using the system's native encoding. If path is NULL or invalid, returns false. If the file is not empty, its content is discarded.
valThe JSON root value. If val is NULL, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA 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.

Definition at line 9735 of file yyjson.c.

References yyjson_write_err::code, constcast, yyjson_alc::ctx, yyjson_alc::free, yyjson_write_err::msg, unlikely, write_dat_to_file(), write_root(), YYJSON_DEFAULT_ALC, and YYJSON_READ_ERROR_INVALID_PARAMETER.

Referenced by yyjson_write_file().

◆ 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
fpThe file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false.
valThe JSON root value. If val is NULL, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA 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.

Definition at line 9761 of file yyjson.c.

References yyjson_write_err::code, constcast, yyjson_alc::ctx, yyjson_alc::free, yyjson_write_err::msg, unlikely, write_dat_to_fp(), write_root(), YYJSON_DEFAULT_ALC, and YYJSON_READ_ERROR_INVALID_PARAMETER.

Referenced by yyjson_write_fp().

◆ 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
valThe JSON root value. If val is NULL, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
lenA pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information.
errA 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().

Definition at line 9716 of file yyjson.c.

References write_root().

Referenced by yyjson_val_write().

◆ yyjson_version()

yyjson_api uint32_t yyjson_version ( void )

The version of yyjson in hex, same as YYJSON_VERSION_HEX.

Definition at line 58 of file yyjson.c.

References 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
docThe JSON document. If doc is NULL or has no root, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
lenA 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().

Definition at line 1471 of file yyjson.h.

References len, yyjson_api_inline, and yyjson_write_opts().

Referenced by native_dynamic_runtime_handle_request(), and write_proof_state_api_response().

◆ yyjson_write_buf()

yyjson_api size_t yyjson_write_buf ( char * buf,
size_t buf_len,
const yyjson_doc * doc,
yyjson_write_flag flg,
yyjson_write_err * err )

Write a document into a buffer.

This function does not allocate memory, but the buffer must be larger than the final JSON size to allow temporary space. See API.md for details.

Parameters
bufThe output buffer. If buf is NULL, returns 0.
buf_lenThe buffer length. If buf_len is too small, returns 0.
docThe JSON document. If doc is NULL or has no root, returns 0.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
The number of bytes written (excluding the null terminator), or 0 on failure.

Definition at line 9821 of file yyjson.c.

References yyjson_doc::root, and yyjson_val_write_buf().

◆ 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
pathThe JSON file's path. This should be a null-terminated string using the system's native encoding. If path is NULL or invalid, returns false. If the file is not empty, its content is discarded.
docThe JSON document. If doc is NULL or has no root, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA 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.

Definition at line 9787 of file yyjson.c.

References yyjson_doc::root, and yyjson_val_write_file().

◆ 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
fpThe file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false.
docThe JSON document. If doc is NULL or has no root, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA 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.

Definition at line 9796 of file yyjson.c.

References yyjson_doc::root, and yyjson_val_write_fp().

◆ yyjson_write_number()

yyjson_api char * yyjson_write_number ( const yyjson_val * val,
char * buf )

Write a JSON number.

Parameters
valA JSON number value to be converted to a string. If val is invalid, returns NULL.
bufA buffer to store the resulting null-terminated string. If buf is NULL, returns NULL. For integer values, the buffer must be at least 21 bytes. For floating-point values, the buffer must be at least 40 bytes.
Returns
On success, returns a pointer to the character after the last written character. On failure, returns NULL.
Note
  • This function is thread-safe and does not allocate memory (when YYJSON_DISABLE_FAST_FP_CONV is not defined).
  • This function will fail and return NULL only in the following cases: 1) val or buf is NULL; 2) val is not a number type; 3) val is inf or nan, and non-standard JSON is explicitly disabled via the YYJSON_DISABLE_NON_STANDARD flag.

Definition at line 8427 of file yyjson.c.

References likely, yyjson_val::tag, yyjson_val_uni::u64, yyjson_val::uni, unlikely, write_f32_raw(), write_f64_raw(), write_f64_raw_fixed(), write_u64(), YYJSON_SUBTYPE_REAL, YYJSON_SUBTYPE_SINT, YYJSON_SUBTYPE_UINT, YYJSON_TAG_MASK, YYJSON_TYPE_NUM, YYJSON_WRITE_ALLOW_INF_AND_NAN, YYJSON_WRITE_FP_FLAG_BITS, YYJSON_WRITE_FP_PREC_BITS, and YYJSON_WRITE_FP_TO_FLOAT.

Referenced by yyjson_mut_write_number().

◆ 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
docThe JSON document. If doc is NULL or has no root, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
lenA pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information.
errA 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().

Definition at line 9724 of file yyjson.c.

References yyjson_doc::root, and write_root().

Referenced by yyjson_write().

Variable Documentation

◆ len

const char size_t len
Initial value:
{
return yyjson_doc_ptr_getn(doc, ptr, len)
yyjson_api_inline yyjson_val * yyjson_doc_ptr_getn(const yyjson_doc *doc, const char *ptr, size_t len)
Definition yyjson.h:7641

Definition at line 8364 of file yyjson.h.

Referenced by app_artifact_dir_from_build_dir_native(), buffer_append(), bytes_to_hex_runtime(), digits_only_runtime(), dup_range(), generated_surface_label_from_field_runtime(), handle_bundle_manifest_slice_order_command(), handle_object_relative_path_array_to_absolute_json_command(), handle_request_lines_to_booking_options_json_command(), is_truncated_end(), is_truncated_str(), is_truncated_utf8(), json_extract_array_in_section(), multipart_dup_range(), native_connection_printf(), native_connection_read(), native_connection_write(), native_dynamic_url_decode(), native_json_doc_load_text(), native_json_string_array_lines_dup(), native_json_string_dup(), native_request_path_without_query(), normalize_base_path_native(), ptr_arr_get(), ptr_mut_arr_get(), ptr_mut_obj_get(), ptr_new_key(), ptr_next_token(), ptr_obj_get(), ptr_token_eq(), ptr_token_to_idx(), runtime_apps_fingerprint_native(), send_all(), serve_dynamic_home_page(), sha256_update_runtime(), shell_quote_runtime_stack_native(), skip_trivia(), stbi_info_from_memory(), stbi_is_16_bit_from_memory(), stbi_is_hdr_from_memory(), stbi_load_16_from_memory(), stbi_load_from_memory(), stbi_load_gif_from_memory(), stbi_loadf_from_memory(), stbi_zlib_decode_malloc(), stbi_zlib_decode_malloc_guesssize(), stbi_zlib_decode_malloc_guesssize_headerflag(), stbi_zlib_decode_noheader_malloc(), trim_ascii_whitespace_range_runtime(), unsafe_yyjson_equals(), unsafe_yyjson_is_str_noesc(), unsafe_yyjson_mut_equals(), unsafe_yyjson_mut_ptr_getx(), unsafe_yyjson_mut_ptr_removex(), unsafe_yyjson_mut_ptr_replacex(), unsafe_yyjson_ptr_getx(), unsafe_yyjson_str_equals(), unsafe_yyjson_str_pool_grow(), url_decode_dup_runtime(), write_dat_to_file(), write_dat_to_fp(), write_f32_raw(), write_f64_raw(), write_f64_raw_fixed(), write_fp_reformat(), yyjson_imut_copy(), yyjson_incr_read(), yyjson_locate_pos(), yyjson_mut_doc_set_str_pool_size(), yyjson_mut_stat(), yyjson_mut_val_write(), yyjson_mut_write(), yyjson_read(), yyjson_read_max_memory_usage(), yyjson_read_opts(), yyjson_val_mut_copy(), yyjson_val_write(), and yyjson_write().

◆ ptr

◆ YYJSON_PATCH_ERROR_EQUAL

const yyjson_patch_code YYJSON_PATCH_ERROR_EQUAL = 6
static

JSON patch test operation failed (values not equal).

Definition at line 4877 of file yyjson.h.

◆ YYJSON_PATCH_ERROR_INVALID_MEMBER

const yyjson_patch_code YYJSON_PATCH_ERROR_INVALID_MEMBER = 5
static

JSON patch operation member is invalid.

Definition at line 4874 of file yyjson.h.

◆ YYJSON_PATCH_ERROR_INVALID_OPERATION

const yyjson_patch_code YYJSON_PATCH_ERROR_INVALID_OPERATION = 3
static

JSON patch operation is not object type.

Definition at line 4868 of file yyjson.h.

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

Definition at line 4862 of file yyjson.h.

◆ YYJSON_PATCH_ERROR_MEMORY_ALLOCATION

const yyjson_patch_code YYJSON_PATCH_ERROR_MEMORY_ALLOCATION = 2
static

Memory allocation failed.

Definition at line 4865 of file yyjson.h.

◆ YYJSON_PATCH_ERROR_MISSING_KEY

const yyjson_patch_code YYJSON_PATCH_ERROR_MISSING_KEY = 4
static

JSON patch operation is missing a required key.

Definition at line 4871 of file yyjson.h.

◆ YYJSON_PATCH_ERROR_POINTER

const yyjson_patch_code YYJSON_PATCH_ERROR_POINTER = 7
static

JSON patch operation failed on JSON pointer.

Definition at line 4880 of file yyjson.h.

◆ YYJSON_PATCH_SUCCESS

const yyjson_patch_code YYJSON_PATCH_SUCCESS = 0
static

Success, no error.

Definition at line 4859 of file yyjson.h.

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

Definition at line 4295 of file yyjson.h.

◆ YYJSON_PTR_ERR_NONE

const yyjson_ptr_code YYJSON_PTR_ERR_NONE = 0
static

No JSON pointer error.

Definition at line 4277 of file yyjson.h.

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

Definition at line 4289 of file yyjson.h.

◆ YYJSON_PTR_ERR_PARAMETER

const yyjson_ptr_code YYJSON_PTR_ERR_PARAMETER = 1
static

Invalid input parameter, such as NULL input.

Definition at line 4280 of file yyjson.h.

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

Definition at line 4286 of file yyjson.h.

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

Definition at line 4292 of file yyjson.h.

◆ YYJSON_PTR_ERR_SYNTAX

const yyjson_ptr_code YYJSON_PTR_ERR_SYNTAX = 2
static

JSON pointer syntax error, such as invalid escape or missing prefix.

Definition at line 4283 of file yyjson.h.

◆ YYJSON_READ_ALLOW_BOM

const yyjson_read_flag YYJSON_READ_ALLOW_BOM = 1 << 8
static

Allow UTF-8 BOM and skip it before parsing if any (non-standard).

Definition at line 856 of file yyjson.h.

Referenced by yyjson_incr_new().

◆ YYJSON_READ_ALLOW_COMMENTS

const yyjson_read_flag YYJSON_READ_ALLOW_COMMENTS = 1 << 3
static

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

Definition at line 829 of file yyjson.h.

◆ YYJSON_READ_ALLOW_EXT_ESCAPE

const yyjson_read_flag YYJSON_READ_ALLOW_EXT_ESCAPE = 1 << 10
static

Allow extended escape sequences in strings (non-standard):

  • Additional escapes: \a, \e, \v, \', \?, \0.
  • Hex escapes: \xNN, such as \x7B.
  • Line continuation: backslash followed by line terminator sequences.
  • Unknown escape: if backslash is followed by an unsupported character, the backslash will be removed and the character will be kept as-is. However, \1-\9 will still trigger an error.

Definition at line 871 of file yyjson.h.

◆ YYJSON_READ_ALLOW_EXT_NUMBER

const yyjson_read_flag YYJSON_READ_ALLOW_EXT_NUMBER = 1 << 9
static

Allow extended number formats (non-standard):

  • Hexadecimal numbers, such as 0x7B.
  • Numbers with leading or trailing decimal point, such as .123, 123..
  • Numbers with a leading plus sign, such as +123.

Definition at line 862 of file yyjson.h.

◆ YYJSON_READ_ALLOW_EXT_WHITESPACE

const yyjson_read_flag YYJSON_READ_ALLOW_EXT_WHITESPACE = 1 << 11
static

Allow extended whitespace characters (non-standard):

  • Vertical tab \v and form feed \f.
  • Line separator \u2028 and paragraph separator \u2029.
  • Non-breaking space \xA0.
  • Byte order mark: \uFEFF.
  • Other Unicode characters in the Zs (Separator, space) category.

Definition at line 879 of file yyjson.h.

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

Definition at line 833 of file yyjson.h.

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

Definition at line 847 of file yyjson.h.

Referenced by yyjson_incr_new().

◆ YYJSON_READ_ALLOW_SINGLE_QUOTED_STR

const yyjson_read_flag YYJSON_READ_ALLOW_SINGLE_QUOTED_STR = 1 << 12
static

Allow strings enclosed in single quotes (non-standard), such as 'ab'.

Definition at line 882 of file yyjson.h.

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

Definition at line 826 of file yyjson.h.

◆ YYJSON_READ_ALLOW_UNQUOTED_KEY

const yyjson_read_flag YYJSON_READ_ALLOW_UNQUOTED_KEY = 1 << 13
static

Allow object keys without quotes (non-standard), such as {a:1,b:2}. This extends the ECMAScript IdentifierName rule by allowing any non-whitespace character with code point above U+007F.

Definition at line 887 of file yyjson.h.

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

Definition at line 853 of file yyjson.h.

◆ YYJSON_READ_ERROR_DEPTH

const yyjson_read_code YYJSON_READ_ERROR_DEPTH = 15
static

Read depth limit exceeded.

Definition at line 955 of file yyjson.h.

◆ YYJSON_READ_ERROR_EMPTY_CONTENT

const yyjson_read_code YYJSON_READ_ERROR_EMPTY_CONTENT = 3
static

Input JSON string is empty.

Definition at line 919 of file yyjson.h.

◆ YYJSON_READ_ERROR_FILE_OPEN

const yyjson_read_code YYJSON_READ_ERROR_FILE_OPEN = 12
static

Failed to open a file.

Definition at line 946 of file yyjson.h.

◆ YYJSON_READ_ERROR_FILE_READ

const yyjson_read_code YYJSON_READ_ERROR_FILE_READ = 13
static

Failed to read a file.

Definition at line 949 of file yyjson.h.

◆ YYJSON_READ_ERROR_INVALID_COMMENT

const yyjson_read_code YYJSON_READ_ERROR_INVALID_COMMENT = 8
static

Invalid comment, deprecated, use UNEXPECTED_END for unclosed comment.

Definition at line 934 of file yyjson.h.

Referenced by is_truncated_end().

◆ YYJSON_READ_ERROR_INVALID_NUMBER

const yyjson_read_code YYJSON_READ_ERROR_INVALID_NUMBER = 9
static

Invalid number, such as 123.e12, 000.

Definition at line 937 of file yyjson.h.

Referenced by is_truncated_end().

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

Definition at line 913 of file yyjson.h.

Referenced by write_root(), yyjson_val_write_file(), and yyjson_val_write_fp().

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

Definition at line 940 of file yyjson.h.

Referenced by is_truncated_end().

◆ YYJSON_READ_ERROR_JSON_STRUCTURE

const yyjson_read_code YYJSON_READ_ERROR_JSON_STRUCTURE = 7
static

Invalid JSON structure, such as [1,].

Definition at line 931 of file yyjson.h.

◆ YYJSON_READ_ERROR_LITERAL

const yyjson_read_code YYJSON_READ_ERROR_LITERAL = 11
static

Invalid JSON literal, such as truu.

Definition at line 943 of file yyjson.h.

Referenced by is_truncated_end().

◆ YYJSON_READ_ERROR_MEMORY_ALLOCATION

const yyjson_read_code YYJSON_READ_ERROR_MEMORY_ALLOCATION = 2
static

Memory allocation failed.

Definition at line 916 of file yyjson.h.

Referenced by yyjson_read_opts().

◆ YYJSON_READ_ERROR_MORE

const yyjson_read_code YYJSON_READ_ERROR_MORE = 14
static

Incomplete input during incremental parsing; parsing state is preserved.

Definition at line 952 of file yyjson.h.

Referenced by yyjson_incr_read().

◆ YYJSON_READ_ERROR_UNEXPECTED_CHARACTER

const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_CHARACTER = 6
static

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

Definition at line 928 of file yyjson.h.

Referenced by is_truncated_end().

◆ YYJSON_READ_ERROR_UNEXPECTED_CONTENT

const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_CONTENT = 4
static

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

Definition at line 922 of file yyjson.h.

Referenced by is_truncated_end().

◆ YYJSON_READ_ERROR_UNEXPECTED_END

const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_END = 5
static

Unexpected end of input, the parsed part is valid, such as [123.

Definition at line 925 of file yyjson.h.

Referenced by yyjson_incr_read().

◆ 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 freeing 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.

Definition at line 817 of file yyjson.h.

Referenced by yyjson_incr_free(), yyjson_read(), yyjson_read_fp(), and yyjson_read_max_memory_usage().

◆ YYJSON_READ_JSON5

const yyjson_read_flag YYJSON_READ_JSON5
static
Initial value:
=
(1 << 2) |
(1 << 3) |
(1 << 4) |
(1 << 9) |
(1 << 10) |
(1 << 11) |
(1 << 12) |
(1 << 13)

Allow JSON5 format, see: [https://json5.org]. This flag supports all JSON5 features with some additional extensions:

  • Accepts more escape sequences than JSON5 (e.g. \a, \e).
  • Unquoted keys are not limited to ECMAScript IdentifierName.
  • Allow case-insensitive NaN, Inf and Infinity literals.

Definition at line 894 of file yyjson.h.

Referenced by yyjson_incr_new().

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

Definition at line 809 of file yyjson.h.

Referenced by native_json_doc_load_text().

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

Definition at line 837 of file yyjson.h.

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

Definition at line 822 of file yyjson.h.

Referenced by yyjson_read_max_memory_usage().

◆ YYJSON_READ_SUCCESS

const yyjson_read_code YYJSON_READ_SUCCESS = 0
static

Success, no error.

Definition at line 910 of file yyjson.h.

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

Definition at line 1257 of file yyjson.h.

Referenced by yyjson_write_number().

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

Definition at line 1268 of file yyjson.h.

◆ YYJSON_WRITE_ERROR_FILE_OPEN

const yyjson_write_code YYJSON_WRITE_ERROR_FILE_OPEN = 5
static

Failed to open a file.

Definition at line 1325 of file yyjson.h.

◆ YYJSON_WRITE_ERROR_FILE_WRITE

const yyjson_write_code YYJSON_WRITE_ERROR_FILE_WRITE = 6
static

Failed to write a file.

Definition at line 1328 of file yyjson.h.

Referenced by write_dat_to_fp().

◆ YYJSON_WRITE_ERROR_INVALID_PARAMETER

const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_PARAMETER = 1
static

Invalid parameter, such as NULL document.

Definition at line 1313 of file yyjson.h.

Referenced by mut_write_root(), yyjson_mut_val_write_buf(), yyjson_mut_val_write_file(), yyjson_mut_val_write_fp(), and yyjson_val_write_buf().

◆ YYJSON_WRITE_ERROR_INVALID_STRING

const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_STRING = 7
static

Invalid unicode in string.

Definition at line 1331 of file yyjson.h.

◆ YYJSON_WRITE_ERROR_INVALID_VALUE_TYPE

const yyjson_write_code YYJSON_WRITE_ERROR_INVALID_VALUE_TYPE = 3
static

Invalid value type in JSON document.

Definition at line 1319 of file yyjson.h.

◆ YYJSON_WRITE_ERROR_MEMORY_ALLOCATION

const yyjson_write_code YYJSON_WRITE_ERROR_MEMORY_ALLOCATION = 2
static

Memory allocation failed.

Definition at line 1316 of file yyjson.h.

◆ YYJSON_WRITE_ERROR_NAN_OR_INF

const yyjson_write_code YYJSON_WRITE_ERROR_NAN_OR_INF = 4
static

NaN or Infinity number occurs.

Definition at line 1322 of file yyjson.h.

◆ YYJSON_WRITE_ESCAPE_SLASHES

const yyjson_write_flag YYJSON_WRITE_ESCAPE_SLASHES = 1 << 2
static

Escape '/' as '\/'.

Definition at line 1254 of file yyjson.h.

◆ YYJSON_WRITE_ESCAPE_UNICODE

const yyjson_write_flag YYJSON_WRITE_ESCAPE_UNICODE = 1 << 1
static

Escape unicode as uXXXX, make the output ASCII only.

Definition at line 1251 of file yyjson.h.

Referenced by build_artifact_local_app_manifest_json().

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

Definition at line 1261 of file yyjson.h.

◆ YYJSON_WRITE_LOWERCASE_HEX

const yyjson_write_flag YYJSON_WRITE_LOWERCASE_HEX = 1 << 8
static

Use lowercase hex digits in \uXXXX escape sequences instead of the default uppercase. Only effective when YYJSON_WRITE_ESCAPE_UNICODE is also set.

Definition at line 1280 of file yyjson.h.

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

Definition at line 1276 of file yyjson.h.

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

Definition at line 1245 of file yyjson.h.

Referenced by append_rate_limit_event_runtime_local(), appointments_render_page_params_json_dup_runtime(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_edit_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_compact_json_mut_value_runtime(), emit_compact_mutable_json_doc_runtime(), emit_json_string_runtime(), explore_render_page_params_json_dup_runtime(), generated_admin_manage_page_params_json_dup_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_generated_surface_default_candidate_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), handle_state_named_command(), handle_template_layout_page_html_command(), issue_browser_session_runtime(), login_page_params_json_dup_runtime(), native_dynamic_runtime_handle_request(), native_json_serialize_compact_dup(), profile_page_params_json_dup_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_home_page_params_json_dup_runtime(), register_page_params_json_dup_runtime(), render_business_fragment_from_doc_dup_runtime(), render_page_html_dup_runtime(), revoke_session_by_cookie_runtime(), runtime_page_params_write_runtime(), service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), write_mutable_json_doc_runtime(), and write_proof_state_api_response().

◆ YYJSON_WRITE_PRETTY

const yyjson_write_flag YYJSON_WRITE_PRETTY = 1 << 0
static

Write JSON pretty with 4 space indent.

Definition at line 1248 of file yyjson.h.

Referenced by build_artifact_local_app_manifest_json(), mut_write_root(), and write_root().

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

Definition at line 1272 of file yyjson.h.

Referenced by mut_write_root(), and write_root().

◆ YYJSON_WRITE_SUCCESS

const yyjson_write_code YYJSON_WRITE_SUCCESS = 0
static

Success, no error.

Definition at line 1310 of file yyjson.h.

Referenced by mut_write_root_minify(), and mut_write_root_pretty().