21. Boost package for JSON
The JSON boost module implements collection of helper macros and functions to accompany JSON.
All functions and symbols are in “json_boost” module, use require to get access to it.
require daslib/json_boost
21.1. Structures
- JsonFieldState
- Fields
argName : string - name of the field in JSON
enumAsInt : bool - whether to parse enum as integer
unescape : bool - whether to unescape strings
embed : bool - whether to embed the field
optional : bool - whether the field is optional
21.2. Reader macros
- json
- This macro implements embedding of the JSON object into the program::
var jsv = %json~ {
“name”: “main_window”, “value”: 500, “size”: [1,2,3]
} %%
21.3. Variant macros
- better_json
This macro is used to implement is json_value and as json_value runtime checks. It essencially substitutes value as name with value.value as name and value is name with value.value is name.
21.4. Value conversion
from_JV (v: JsonValue const?; ent: auto(EnumT); defV: EnumT = EnumT()) : EnumT
from_JV (v: JsonValue const?; ent: string; defV: string = “”) : auto
from_JV (v: JsonValue const?; ent: bool; defV: bool = false) : auto
from_JV (v: JsonValue const?; ent: float; defV: float = 0f) : auto
from_JV (v: JsonValue const?; ent: double; defV: double = 0lf) : auto
from_JV (v: JsonValue const?; ent: int; defV: int = 0) : auto
from_JV (v: JsonValue const?; ent: uint; defV: uint = 0x0) : auto
from_JV (v: JsonValue const?; ent: int64; defV: int64 = 0) : auto
from_JV (v: JsonValue const?; ent: uint64; defV: uint64 = 0x0) : auto
from_JV (v: JsonValue const?; ent: int8; defV: int8 = int8(0)) : auto
from_JV (v: JsonValue const?; ent: uint8; defV: uint8 = uint8(0)) : auto
from_JV (v: JsonValue const?; ent: int16; defV: int16 = int16(0)) : auto
from_JV (v: JsonValue const?; ent: uint16; defV: uint16 = uint16(0)) : auto
from_JV (v: JsonValue const?; ent: bitfield; defV: bitfield = bitfield()) : auto
from_JV (v: JsonValue const?; ent: bitfield8:uint8<>; defV: bitfield8 = bitfield8()) : auto
from_JV (v: JsonValue const?; ent: bitfield16:uint16<>; defV: bitfield16 = bitfield16()) : auto
from_JV (v: JsonValue const?; ent: bitfield64:uint64<>; defV: bitfield64 = bitfield64()) : auto
from_JV (v: JsonValue const?; ent: auto(VecT); defV: VecT = VecT()) : auto
from_JV (v: JsonValue const?; anything: table<auto(KT), auto(VT)>) : auto
JV (val1: auto; val2: auto; val3: auto; val4: auto) : JsonValue?
JV (val1: auto; val2: auto; val3: auto; val4: auto; val5: auto) : JsonValue?
JV (val1: auto; val2: auto; val3: auto; val4: auto; val5: auto; val6: auto) : JsonValue?
JV (val1: auto; val2: auto; val3: auto; val4: auto; val5: auto; val6: auto; val7: auto) : JsonValue?
- from_JV(v: JsonValue const?; ent: auto(EnumT); defV: EnumT = EnumT()) : EnumT()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : auto(EnumT)
defV : EnumT
- from_JV(v: JsonValue const?; ent: string; defV: string = "") : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : string
defV : string
- from_JV(v: JsonValue const?; ent: bool; defV: bool = false) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : bool
defV : bool
- from_JV(v: JsonValue const?; ent: float; defV: float = 0f) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : float
defV : float
- from_JV(v: JsonValue const?; ent: double; defV: double = 0lf) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : double
defV : double
- from_JV(v: JsonValue const?; ent: int; defV: int = 0) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : int
defV : int
- from_JV(v: JsonValue const?; ent: uint; defV: uint = 0x0) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : uint
defV : uint
- from_JV(v: JsonValue const?; ent: int64; defV: int64 = 0) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : int64
defV : int64
- from_JV(v: JsonValue const?; ent: uint64; defV: uint64 = 0x0) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : uint64
defV : uint64
- from_JV(v: JsonValue const?; ent: int8; defV: int8 = int8(0)) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : int8
defV : int8
- from_JV(v: JsonValue const?; ent: uint8; defV: uint8 = uint8(0)) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : uint8
defV : uint8
- from_JV(v: JsonValue const?; ent: int16; defV: int16 = int16(0)) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : int16
defV : int16
- from_JV(v: JsonValue const?; ent: uint16; defV: uint16 = uint16(0)) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : uint16
defV : uint16
- from_JV(v: JsonValue const?; ent: bitfield; defV: bitfield = bitfield()) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : bitfield<>
defV : bitfield<>
- from_JV(v: JsonValue const?; ent: bitfield8:uint8<>; defV: bitfield8 = bitfield8()) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : bitfield : uint8<>
defV : bitfield8
- from_JV(v: JsonValue const?; ent: bitfield16:uint16<>; defV: bitfield16 = bitfield16()) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : bitfield : uint16<>
defV : bitfield16
- from_JV(v: JsonValue const?; ent: bitfield64:uint64<>; defV: bitfield64 = bitfield64()) : auto()
Parse a JSON value and return the corresponding native value.
- Arguments
v : JsonValue ?
ent : bitfield : uint64<>
defV : bitfield64
- JV(v: auto(VecT)) : auto()
Creates JsonValue out of value.
- Arguments
v : auto(VecT)
- from_JV(v: JsonValue const?; ent: auto(VecT); defV: VecT = VecT()) : auto()
Parse a JSON value and return the corresponding vector value.
- Arguments
v : JsonValue ?
ent : auto(VecT)
defV : VecT
- from_JV(v: JsonValue const?; anything: table<auto(KT), auto(VT)>) : auto()
Parse a JSON value and return the corresponding table value.
- Arguments
v : JsonValue ?
anything : table<auto(KT);auto(VT)>
- from_JV(v: JsonValue const?; anything: auto(TT)) : auto()
Parse a JSON value and return the corresponding value of any type. This is the main dispatch function that handles various types.
- Arguments
v : JsonValue ?
anything : auto(TT)
- JV(value: auto(TT)) : JsonValue?()
Creates JsonValue out of value. This is the main dispatch function that handles various types.
- Arguments
value : auto(TT)
- JV(val1: auto; val2: auto) : JsonValue?()
Creates array of two JsonValues.
- Arguments
val1 : auto
val2 : auto
- JV(val1: auto; val2: auto; val3: auto) : JsonValue?()
Creates array of three JsonValues.
- Arguments
val1 : auto
val2 : auto
val3 : auto
- JV(val1: auto; val2: auto; val3: auto; val4: auto) : JsonValue?()
Creates array of four JsonValues.
- Arguments
val1 : auto
val2 : auto
val3 : auto
val4 : auto
- JV(val1: auto; val2: auto; val3: auto; val4: auto; val5: auto) : JsonValue?()
Creates array of five JsonValues.
- Arguments
val1 : auto
val2 : auto
val3 : auto
val4 : auto
val5 : auto
- JV(val1: auto; val2: auto; val3: auto; val4: auto; val5: auto; val6: auto) : JsonValue?()
Creates array of six JsonValues.
- Arguments
val1 : auto
val2 : auto
val3 : auto
val4 : auto
val5 : auto
val6 : auto
- JV(val1: auto; val2: auto; val3: auto; val4: auto; val5: auto; val6: auto; val7: auto) : JsonValue?()
Creates array of seven JsonValues.
- Arguments
val1 : auto
val2 : auto
val3 : auto
val4 : auto
val5 : auto
val6 : auto
val7 : auto
- JV(val1: auto; val2: auto; val3: auto; val4: auto; val5: auto; val6: auto; val7: auto; val8: auto) : JsonValue?()
Creates array of eight JsonValues.
- Arguments
val1 : auto
val2 : auto
val3 : auto
val4 : auto
val5 : auto
val6 : auto
val7 : auto
val8 : auto
- JV(val1: auto; val2: auto; val3: auto; val4: auto; val5: auto; val6: auto; val7: auto; val8: auto; val9: auto) : JsonValue?()
Creates array of nine JsonValues.
- Arguments
val1 : auto
val2 : auto
val3 : auto
val4 : auto
val5 : auto
val6 : auto
val7 : auto
val8 : auto
val9 : auto
- JV(val1: auto; val2: auto; val3: auto; val4: auto; val5: auto; val6: auto; val7: auto; val8: auto; val9: auto; val10: auto) : JsonValue?()
Creates array of ten JsonValues.
- Arguments
val1 : auto
val2 : auto
val3 : auto
val4 : auto
val5 : auto
val6 : auto
val7 : auto
val8 : auto
val9 : auto
val10 : auto
21.5. Uncategorized
- JsonValue const? ==const?[](a: JsonValue const? ==const; key: string) : JsonValue?()
Returns the value of the key in the JSON object, if it exists.
- Arguments
a : JsonValue ?!
key : string
- JsonValue? ==const?[](a: JsonValue? ==const; key: string) : JsonValue?()
Returns the value of the key in the JSON object, if it exists.
- Arguments
a : JsonValue ?!
key : string
- JsonValue const? ==const?.(a: JsonValue const? ==const; key: string) : JsonValue?()
Returns the value of the key in the JSON object, if it exists.
- Arguments
a : JsonValue ?!
key : string
- JsonValue? ==const?.(a: JsonValue? ==const; key: string) : JsonValue?()
Returns the value of the key in the JSON object, if it exists.
- Arguments
a : JsonValue ?!
key : string
- JsonValue const? ==const?[](a: JsonValue const? ==const; idx: int) : JsonValue?()
Returns the value of the index in the JSON array, if it exists.
- Arguments
a : JsonValue ?!
idx : int
- JsonValue? ==const?[](a: JsonValue? ==const; idx: int) : JsonValue?()
Returns the value of the index in the JSON array, if it exists.
- Arguments
a : JsonValue ?!
idx : int
- JsonValue const???(a: JsonValue const?; val: double) : double()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : double
- JsonValue const???(a: JsonValue const?; val: float) : float()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : float
- JsonValue const???(a: JsonValue const?; val: int8) : int8()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : int8
- JsonValue const???(a: JsonValue const?; val: int16) : int16()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : int16
- JsonValue const???(a: JsonValue const?; val: int) : int()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : int
- JsonValue const???(a: JsonValue const?; val: int64) : int64()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : int64
- JsonValue const???(a: JsonValue const?; val: uint8) : uint8()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : uint8
- JsonValue const???(a: JsonValue const?; val: uint16) : uint16()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : uint16
- JsonValue const???(a: JsonValue const?; val: uint) : uint()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : uint
- JsonValue const???(a: JsonValue const?; val: uint64) : uint64()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : uint64
- JsonValue const???(a: JsonValue const?; val: bool) : bool()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : bool
- JsonValue const???(a: JsonValue const?; val: string) : string()
Returns the value of the JSON object, if it exists, otherwise returns the default value.
- Arguments
a : JsonValue ?
val : string
- JsonValue const? ==const?.`value(a: JsonValue const? ==const) : variant<_object:table<string;JsonValue?>;_array:array<JsonValue?>;_string:string;_number:double;_longint:int64;_bool:bool;_null:void?> const?()
Returns the value of the JSON object, if it exists.
- Arguments
a : JsonValue ?!
- JsonValue? ==const?.`value(a: JsonValue? ==const) : variant<_object:table<string;JsonValue?>;_array:array<JsonValue?>;_string:string;_number:double;_longint:int64;_bool:bool;_null:void?>?()
Returns the value of the JSON object, if it exists.
- Arguments
a : JsonValue ?!
- parse_json_annotation(name: string; annotation: array<tuple<name:string;data:variant<tBool:bool;tInt:int;tUInt:uint;tInt64:int64;tUInt64:uint64;tFloat:float;tDouble:double;tString:string;nothing:any>>>) : JsonFieldState()
Parse JSON field annotations and return the corresponding JsonFieldState.
- Arguments
name : string
annotation : array<tuple<name:string;data: RttiValue >>