Packages

builtin
cbindgen
core
core.alloc
core.alloc.arena
core.alloc.atomic
core.alloc.fixed
core.alloc.gc
core.alloc.heap
core.alloc.log
core.alloc.memdebug
core.alloc.pool
core.alloc.ring
core.arg_parse
core.array
core.avl_tree
core.bucket_array
core.conv
core.doc
core.encoding
core.encoding.base64
core.encoding.csv
core.encoding.hex
core.encoding.json
core.encoding.kdl
core.encoding.osad
core.encoding.utf8
core.hash
core.hash.md5
core.hash.sha1
core.hash.sha256
core.heap
core.intrinsics
core.intrinsics.atomics
core.intrinsics.onyx
core.intrinsics.types
core.intrinsics.wasm
core.io
core.io.binary
core.iter
core.js
core.list
core.map
core.math
core.memory
core.misc
core.net
core.os
core.random
core.set
core.slice
core.string
core.sync
core.test
core.thread
core.time
main
runtime
runtime.info
runtime.platform
runtime.vars
simd

package core.encoding.json

Custom_Key
Custom_Key :: struct {
    key: [] u8;
}
Error
Error :: struct {
    kind: Error.Kind;
    pos: Position;
}
Json
Json :: struct {
    allocator: Allocator;
    root: Value;
}
_Decode_Error
_Decode_Error :: struct {
    errmsg: [] u8;
    pos: Position;
}
Encoding_Error
Encoding_Error :: enum {
    None :: 0;
    Unsupported_Type :: 1;
}
Value_Type
Value_Type :: enum {
    Null :: 0;
    Bool :: 1;
    Integer :: 2;
    Float :: 3;
    String :: 4;
    Array :: 5;
    Object :: 6;
}
Decode_Error
Decode_Error :: #distinct &_Decode_Error
Methods
Decode_Error.has_error
Decode_Error.has_error :: (this: Decode_Error) -> bool
Decode_Error.message
Decode_Error.message :: (this: Decode_Error) -> [] u8
Decode_Error.position
Decode_Error.position :: (this: Decode_Error) -> Position
Ignore
Ignore :: #distinct void
Value
Value :: #distinct &_Value
Methods
Value.as_array
Value.as_array :: (v: Value) -> [..] Value
Value.as_array_iter
Value.as_array_iter :: (v: Value) -> Iterator(Value)
Value.as_bool
Value.as_bool :: (v: Value) -> bool
Value.as_float
Value.as_float :: (v: Value) -> f64
Value.as_int
Value.as_int :: (v: Value) -> i64
Value.as_map
Value.as_map :: (v: Value) -> Map([] u8, Value)
Value.as_map_iter
Value.as_map_iter :: (v: Value) -> Iterator(Pair([] u8, Value))
Value.as_str
Value.as_str :: (v: Value) -> [] u8
Value.is_null
Value.is_null :: (v: Value) -> bool
Value.type
Value.type :: (v: Value) -> Value_Type
as_any
as_any :: macro (value: Value, $T: type_expr) -> T
as_any :: macro (value: Value, out: &$T) -> void
as_any :: (value: Value, type: type_expr, out: rawptr) -> void
consume_token
consume_token :: (parser: &Parser) -> (Token, Error)
consume_token_if_next
consume_token_if_next :: (parser: &Parser, kind: Token.Kind) -> bool
decode
decode :: (data: [] u8, allocator: Allocator, print_errors: bool) -> Json

Unsafely decodes a strings into a json object, returning an invalid Json value if it failed to parse.

This procedure is not very useful and should be considered deprecated.

decode_into
decode_into :: (data: str, out: &$T) -> Error

Decodes a string into any Onyx type.

Internally uses decode_with_result and as_any.

decode_with_error
decode_with_error :: (data: [] u8, allocator: Allocator) -> (Json, Decode_Error)

Decodes a string into a Json object, and returns the Json object and and a Decode_Error that is non-null if an error occured.

This procedure should be considered deprecated in favor of decode_with_result.

decode_with_result
decode_with_result :: (data: [] u8, allocator: Allocator) -> Result(Json, Error)

Decodes a string into a possible Json object. If parsing fails, an error is returned instead.

empty_object
empty_object :: (allocator: Allocator) -> Value
encode
encode :: (w: &Writer, v: i32) -> Encoding_Error
encode :: (w: &Writer, v: i64) -> Encoding_Error
encode :: (w: &Writer, v: f32) -> Encoding_Error
encode :: (w: &Writer, v: f64) -> Encoding_Error
encode :: (w: &Writer, v: [] u8) -> Encoding_Error
encode :: (w: &io.Writer, v: [] $T) -> Encoding_Error
encode :: (w: &io.Writer, v: [..] $T) -> Encoding_Error
encode :: (w: &io.Writer, v: Map(str, $T)) -> Encoding_Error
encode :: (w: &Writer, v: Value) -> Encoding_Error
encode :: (w: &Writer, data: any) -> Encoding_Error
encode_string
encode_string :: (v: $T, allocator) -> (str, Encoding_Error)
encode_string_opt
encode_string_opt :: (v: $T, allocator) -> ? str
expect_token
expect_token :: (parser: &Parser, kind: Token.Kind) -> (Token, Error)
free
free :: (v: Value, allocator: Allocator) -> void
free :: (j: Json) -> void
from_any
from_any :: macro (v: &$T, allocator) -> Value
from_any :: (type: type_expr, input: rawptr, allocator: Allocator) -> Value
get
get :: (v: Value, key: [] u8) -> Value
get_idx
get_idx :: (v: Value, idx: i32) -> Value
next_character
next_character :: (tkn: &Tokenizer) -> (u8, bool)
null_value
null_value :: () -> Value
parse_and_write_utf8_character
parse_and_write_utf8_character :: (s: [] u8, out: [&] u8) -> (i32, i32)
parse_array
parse_array :: (parser: &Parser) -> (Value, Error)
parse_object
parse_object :: (parser: &Parser) -> (Value, Error)
set
set :: macro (v: Value, key: [] u8, value: Value, dont_copy_key: bool) -> void
set :: macro (v: Value, key: [] u8, value: [] u8, dont_copy_key: bool, dont_copy_value: bool) -> i32
skip_alpha_numeric
skip_alpha_numeric :: (tkn: &Tokenizer) -> void
skip_escape
skip_escape :: (tkn: &Tokenizer) -> void
skip_numeric
skip_numeric :: (tkn: &Tokenizer) -> void
skip_whitespace
skip_whitespace :: (tkn: &Tokenizer) -> void
static_string
static_string :: (s: [] u8) -> _Value_String
unescape_string
unescape_string :: (token: Token, allocator: Allocator) -> [] u8