x.json2.decoder2 #
fn decode #
fn decode[T](val string) !T
decode decodes a JSON string into a specified type.
fn decode_array #
deprecated: use `decode` instead
deprecated_after: 2025-03-18
fn decode_array[T](src string) !T
decode_array is a generic function that decodes a JSON string into the array target type.
interface BooleanDecoder #
interface BooleanDecoder {
mut:
// called with converted bool
// already checked so no error needed
from_json_boolean(boolean_value bool)
}
implements decoding json true/false
interface NullDecoder #
interface NullDecoder {
mut:
// only has one value
// already checked so no error needed
from_json_null()
}
implements decoding json null
interface NumberDecoder #
interface NumberDecoder {
mut:
// called with raw string of number e.g. '-1.234e23'
from_json_number(raw_number string) !
}
implements decoding json numbers, e.g. -1.234e23
interface StringDecoder #
interface StringDecoder {
mut:
// called with raw string (minus apostrophes) e.g. 'hello, \u2164!'
from_json_string(raw_string string) !
}
implements decoding json strings, e.g. "hello, \u2164!"
struct JsonDecodeError #
struct JsonDecodeError {
Error
context string
pub:
message string
line int
character int
}