Loading...
Searching...
No Matches
jsonbourne.h
Go to the documentation of this file.
155 JSONBOURNE_READ_ALLOW_TRAILING_COMMAS = 0x0002, /**< Permit a comma before container closure. */
156 JSONBOURNE_READ_ALLOW_UNQUOTED_KEY = 0x0004, /**< Permit nonempty ASCII identifier-like keys. */
159 JSONBOURNE_READ_ALLOW_NO_COMMAS = 0x0020, /**< Permit adjacent members/elements without commas. */
162 JSONBOURNE_READ_TRACK_LOCATION = 0x0100, /**< Allocate location extensions for values and keys. */
163 JSONBOURNE_READ_ALLOW_SINGLE_QUOTED_STR = 0x0200, /**< Permit single quotes and escaped apostrophes. */
168 JSONBOURNE_READ_ALLOW_MULTILINE_STR = 0x4000, /**< Permit raw CR/LF and escaped line continuations. */
271 JSONBOURNE_READ_ERROR_EXPECTED_SEPARATOR, /**< Missing comma/closure or disallowed trailing comma. */
279 JSONBOURNE_READ_ERROR_MEMORY_ALLOCATION, /**< Allocation failed or caller storage is insufficient. */
280 JSONBOURNE_READ_ERROR_UNEXPECTED_CONTENT, /**< Non-trivia bytes follow a complete root value. */
286 JSONBOURNE_READ_ERROR_INVALID_PARAMETER /**< Invalid flags, limits, input or storage alignment. */
351JSONBOURNE_API int jsonbourne_read_measure(const void *src, size_t len, jsonbourne_read_flag flg,
366JSONBOURNE_API int jsonbourne_read_validate(const void *src, size_t len, jsonbourne_read_flag flg,
478JSONBOURNE_API void *jsonbourne_val_write_pretty_opts(const jsonbourne_val *val, const char *indent,
521JSONBOURNE_API int jsonbourne_val_write_pretty_buf(const jsonbourne_val *val, const char *indent,
536jsonbourne_val_copy_opts(const jsonbourne_val *val, void *(*alc_fn)(void *, size_t), void *alc_ctx);
612JSONBOURNE_API const jsonbourne_val *jsonbourne_obj_getn(const jsonbourne_val *val, const char *key,
JSONBOURNE_API int jsonbourne_num_to_sint(const jsonbourne_num *num, int64_t *out)
Convert a signed decimal integer token exactly, including INT64_MIN.
Definition jsonbourne.c:2031
JSONBOURNE_API int jsonbourne_is_null(const jsonbourne_val *val)
Distinguish JSON null from a missing C pointer.
Definition jsonbourne.c:1936
JSONBOURNE_API const jsonbourne_val * jsonbourne_ptr_getn(const jsonbourne_val *val, const char *pointer, size_t len)
Resolve an RFC 6901 pointer without allocating decoded path tokens.
Definition jsonbourne.c:2075
JSONBOURNE_API const jsonbourne_val * jsonbourne_arr_get(const jsonbourne_val *val, size_t idx)
Locate a zero-based array element by bounded linked traversal.
Definition jsonbourne.c:1991
JSONBOURNE_API int jsonbourne_is_false(const jsonbourne_val *val)
Test the false tag without truthiness conversion.
Definition jsonbourne.c:1932
JSONBOURNE_API const char * jsonbourne_read_err_desc(jsonbourne_read_code code)
Borrow human-readable diagnostic text without allocating.
Definition jsonbourne.c:2138
JSONBOURNE_API const jsonbourne_val * jsonbourne_obj_getn(const jsonbourne_val *val, const char *key, size_t len)
Find the first exact decoded member name, including embedded NUL bytes.
Definition jsonbourne.c:1982
JSONBOURNE_API int jsonbourne_num_to_uint(const jsonbourne_num *num, uint64_t *out)
Convert an unsigned decimal integer token exactly, without coercion.
Definition jsonbourne.c:2013
JSONBOURNE_API jsonbourne_arr * jsonbourne_get_arr(jsonbourne_val *val)
Borrow the ordered array payload.
Definition jsonbourne.c:1924
JSONBOURNE_API jsonbourne_obj * jsonbourne_get_obj(jsonbourne_val *val)
Borrow the ordered object payload.
Definition jsonbourne.c:1920
JSONBOURNE_API jsonbourne_str * jsonbourne_get_str(jsonbourne_val *val)
Borrow a string payload without allocating or copying.
Definition jsonbourne.c:1912
JSONBOURNE_API const jsonbourne_val * jsonbourne_obj_getn_unique(const jsonbourne_val *val, const char *key, size_t len)
Require exactly one decoded matching key instead of silently choosing.
Definition jsonbourne.c:1986
JSONBOURNE_API int jsonbourne_is_true(const jsonbourne_val *val)
Test the true tag without coercing numbers or strings.
Definition jsonbourne.c:1928
JSONBOURNE_API jsonbourne_num * jsonbourne_get_num(jsonbourne_val *val)
Borrow the original number-token view.
Definition jsonbourne.c:1916
JSONBOURNE_API uint32_t jsonbourne_version(void)
Query the linked implementation rather than the including header.
Definition jsonbourne.c:104
#define JSONBOURNE_API
Optional declaration annotation for a consumer's visibility/export policy.
Definition jsonbourne.h:133
size_t jsonbourne_read_code
Stable storage type for a diagnostic code, separate from display text.
Definition jsonbourne.h:267
jsonbourne_type
Payload tag; literals need no separately allocated payload.
Definition jsonbourne.h:178
size_t jsonbourne_read_flag
Read-option bitmask; combine named options with bitwise OR.
Definition jsonbourne.h:147
jsonbourne_read_code_e
Reader failures; zero denotes success and leaves error coordinates zeroed.
Definition jsonbourne.h:269
jsonbourne_read_flag_e
Independent reader options and convenience presets.
Definition jsonbourne.h:153
@ JSONBOURNE_READ_ERROR_INVALID_NUMBER
Definition jsonbourne.h:275
@ JSONBOURNE_READ_ERROR_EXPECTED_SEPARATOR
Definition jsonbourne.h:271
@ JSONBOURNE_READ_ERROR_EXPECTED_COLON
Definition jsonbourne.h:272
@ JSONBOURNE_READ_ERROR_INVALID_PARAMETER
Definition jsonbourne.h:286
@ JSONBOURNE_READ_ERROR_MEMORY_ALLOCATION
Definition jsonbourne.h:279
@ JSONBOURNE_READ_ERROR_UNEXPECTED_END
Definition jsonbourne.h:277
@ JSONBOURNE_READ_ERROR_INVALID_STRING
Definition jsonbourne.h:278
@ JSONBOURNE_READ_ERROR_INVALID_COMMENT
Definition jsonbourne.h:282
@ JSONBOURNE_READ_ERROR_UNEXPECTED_CONTENT
Definition jsonbourne.h:280
@ JSONBOURNE_READ_ERROR_INVALID_ESCAPE
Definition jsonbourne.h:274
@ JSONBOURNE_READ_ALLOW_TRAILING_COMMAS
Definition jsonbourne.h:155
@ JSONBOURNE_READ_ALLOW_SINGLE_QUOTED_STR
Definition jsonbourne.h:163
JSONBOURNE_API jsonbourne_val * jsonbourne_read(const void *src, size_t len)
Read strict JSON with default limits and malloc-backed ownership.
Definition jsonbourne.c:1180
JSONBOURNE_API jsonbourne_val * jsonbourne_read_opts_with_limits(const void *src, size_t len, jsonbourne_read_flag flg, const jsonbourne_read_limits *limits, void *(*alc_fn)(void *, size_t), void *alc_ctx, jsonbourne_read_err *err)
Validate against explicit budgets, then allocate the entire DOM once.
Definition jsonbourne.c:1147
JSONBOURNE_API int jsonbourne_read_measure(const void *src, size_t len, jsonbourne_read_flag flg, const jsonbourne_read_limits *limits, size_t *required, jsonbourne_read_err *err)
Validate input and measure the exact single-allocation DOM size.
Definition jsonbourne.c:1043
JSONBOURNE_API jsonbourne_val * jsonbourne_read_opts(const void *src, size_t len, jsonbourne_read_flag flg, void *(*alc_fn)(void *, size_t), void *alc_ctx, jsonbourne_read_err *err)
Read with named options and the linked implementation's default limits.
Definition jsonbourne.c:1174
struct jsonbourne_read_limits jsonbourne_read_limits_default(void)
Create default budgets using the linked implementation's reader limit.
Definition jsonbourne.c:106
JSONBOURNE_API jsonbourne_val * jsonbourne_read_buf(const void *src, size_t len, jsonbourne_read_flag flg, const jsonbourne_read_limits *limits, void *buf, size_t cap, size_t *required, jsonbourne_read_err *err)
Read a DOM into aligned caller storage without heap allocation.
Definition jsonbourne.c:1123
JSONBOURNE_API int jsonbourne_read_validate(const void *src, size_t len, jsonbourne_read_flag flg, const jsonbourne_read_limits *limits, jsonbourne_read_err *err)
Validate the entire extent without allocating a DOM or changing input.
Definition jsonbourne.c:1060
JSONBOURNE_API void * jsonbourne_val_write_pretty_opts(const jsonbourne_val *val, const char *indent, const char *newline, void *(*alc_fn)(void *, size_t), void(*free_fn)(void *, void *), void *alc_ctx, size_t *out_len)
Validate and allocate pretty output with explicit formatting/ownership.
Definition jsonbourne.c:1644
JSONBOURNE_API void * jsonbourne_val_write(const jsonbourne_val *val, size_t *out_len)
Allocate minified JSON using malloc.
Definition jsonbourne.c:1640
JSONBOURNE_API int jsonbourne_val_write_buf(const jsonbourne_val *val, char *buf, size_t cap, size_t *out_len)
Preflight minified output, then write only if the caller buffer fits.
Definition jsonbourne.c:1690
JSONBOURNE_API void * jsonbourne_val_write_pretty(const jsonbourne_val *val, const char *indent, const char *newline, size_t *out_len)
Allocate pretty JSON using malloc.
Definition jsonbourne.c:1651
JSONBOURNE_API jsonbourne_val * jsonbourne_val_copy(const jsonbourne_val *val)
Make an independently owned deep copy using malloc.
Definition jsonbourne.c:1907
JSONBOURNE_API jsonbourne_val * jsonbourne_val_copy_opts(const jsonbourne_val *val, void *(*alc_fn)(void *, size_t), void *alc_ctx)
Deep-copy a validated value into one independent allocation.
Definition jsonbourne.c:1870
JSONBOURNE_API int jsonbourne_val_write_pretty_buf(const jsonbourne_val *val, const char *indent, const char *newline, char *buf, size_t cap, size_t *out_len)
Preflight pretty output without allocating storage.
Definition jsonbourne.c:1694
JSONBOURNE_API void * jsonbourne_val_write_opts(const jsonbourne_val *val, void *(*alc_fn)(void *, size_t), void(*free_fn)(void *, void *), void *alc_ctx, size_t *out_len)
Validate a DOM and allocate minified JSON output.
Definition jsonbourne.c:1635
Ordered array elements; explicit length supports bounded traversal.
Definition jsonbourne.h:240
Original number spelling, retained so reading never rounds through a double.
Definition jsonbourne.h:208
One object member; linked order and duplicate decoded keys are retained.
Definition jsonbourne.h:219
Ordered object members; len must exactly match the linked-list length.
Definition jsonbourne.h:226
Optional read result; coordinates describe the parser's failure cursor.
Definition jsonbourne.h:290
Per-read budgets checked during validation, before a DOM is allocated.
Definition jsonbourne.h:303
Decoded UTF-8 bytes; len, not strlen(), determines the string's extent.
Definition jsonbourne.h:189
Value view followed by coordinates recorded only with TRACK_LOCATION.
Definition jsonbourne.h:259
Tagged DOM value; children and text borrow the root allocation's lifetime.
Definition jsonbourne.h:250