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
JsonFieldState

JsonFieldState fields are

argName

string

enumAsInt

bool

unescape

bool

embed

bool

optional

bool

options for JSON field serialization.

21.1. 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.2. 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.3. Value conversion

from_JV(v: JsonValue const? const; ent: auto(EnumT) const; defV: EnumT const)

from_JV returns EnumT

argument

argument type

v

json::JsonValue const? const

ent

auto(EnumT) const

defV

EnumT const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: string const; defV: string const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

string const

defV

string const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: bool const; defV: bool const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

bool const

defV

bool const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: float const; defV: float const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

float const

defV

float const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: double const; defV: double const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

double const

defV

double const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: int const; defV: int const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

int const

defV

int const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: uint const; defV: uint const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

uint const

defV

uint const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: int64 const; defV: int64 const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

int64 const

defV

int64 const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: uint64 const; defV: uint64 const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

uint64 const

defV

uint64 const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: int8 const; defV: int8 const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

int8 const

defV

int8 const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: uint8 const; defV: uint8 const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

uint8 const

defV

uint8 const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: int16 const; defV: int16 const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

int16 const

defV

int16 const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: uint16 const; defV: uint16 const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

uint16 const

defV

uint16 const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: bitfield const; defV: bitfield const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

bitfield<> const

defV

bitfield<> const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: bitfield8 const; defV: bitfield8 const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

bitfield8 const

defV

bitfield8 const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: bitfield16 const; defV: bitfield16 const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

bitfield16 const

defV

bitfield16 const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; ent: bitfield64 const; defV: bitfield64 const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

bitfield64 const

defV

bitfield64 const

Parse a JSON value and return the corresponding native value.

JV(v: auto(VecT) const)

JV returns auto

argument

argument type

v

auto(VecT) const

skip functions skip void? we only need to handle it as we are writing out, reading handles it at the enum level skip functions skip void?

from_JV(v: JsonValue const? const; ent: auto(VecT) const; defV: VecT const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

ent

auto(VecT) const

defV

VecT const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; anything: table<auto(KT);auto(VT)> const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

anything

table<auto(KT);auto(VT)> const

Parse a JSON value and return the corresponding native value.

from_JV(v: JsonValue const? const; anything: auto(TT) const)

from_JV returns auto

argument

argument type

v

json::JsonValue const? const

anything

auto(TT) const

Parse a JSON value and return the corresponding native value.

JV(value: auto(TT) const)

JV returns json::JsonValue ?

argument

argument type

value

auto(TT) const

skip functions skip void? we only need to handle it as we are writing out, reading handles it at the enum level skip functions skip void?

JV(val1: auto const; val2: auto const)

JV returns json::JsonValue ?

argument

argument type

val1

auto const

val2

auto const

skip functions skip void? we only need to handle it as we are writing out, reading handles it at the enum level skip functions skip void?

JV(val1: auto const; val2: auto const; val3: auto const)

JV returns json::JsonValue ?

argument

argument type

val1

auto const

val2

auto const

val3

auto const

skip functions skip void? we only need to handle it as we are writing out, reading handles it at the enum level skip functions skip void?

JV(val1: auto const; val2: auto const; val3: auto const; val4: auto const)

JV returns json::JsonValue ?

argument

argument type

val1

auto const

val2

auto const

val3

auto const

val4

auto const

skip functions skip void? we only need to handle it as we are writing out, reading handles it at the enum level skip functions skip void?

JV(val1: auto const; val2: auto const; val3: auto const; val4: auto const; val5: auto const)

JV returns json::JsonValue ?

argument

argument type

val1

auto const

val2

auto const

val3

auto const

val4

auto const

val5

auto const

skip functions skip void? we only need to handle it as we are writing out, reading handles it at the enum level skip functions skip void?

JV(val1: auto const; val2: auto const; val3: auto const; val4: auto const; val5: auto const; val6: auto const)

JV returns json::JsonValue ?

argument

argument type

val1

auto const

val2

auto const

val3

auto const

val4

auto const

val5

auto const

val6

auto const

skip functions skip void? we only need to handle it as we are writing out, reading handles it at the enum level skip functions skip void?

JV(val1: auto const; val2: auto const; val3: auto const; val4: auto const; val5: auto const; val6: auto const; val7: auto const)

JV returns json::JsonValue ?

argument

argument type

val1

auto const

val2

auto const

val3

auto const

val4

auto const

val5

auto const

val6

auto const

val7

auto const

skip functions skip void? we only need to handle it as we are writing out, reading handles it at the enum level skip functions skip void?

JV(val1: auto const; val2: auto const; val3: auto const; val4: auto const; val5: auto const; val6: auto const; val7: auto const; val8: auto const)

JV returns json::JsonValue ?

argument

argument type

val1

auto const

val2

auto const

val3

auto const

val4

auto const

val5

auto const

val6

auto const

val7

auto const

val8

auto const

skip functions skip void? we only need to handle it as we are writing out, reading handles it at the enum level skip functions skip void?

JV(val1: auto const; val2: auto const; val3: auto const; val4: auto const; val5: auto const; val6: auto const; val7: auto const; val8: auto const; val9: auto const)

JV returns json::JsonValue ?

argument

argument type

val1

auto const

val2

auto const

val3

auto const

val4

auto const

val5

auto const

val6

auto const

val7

auto const

val8

auto const

val9

auto const

skip functions skip void? we only need to handle it as we are writing out, reading handles it at the enum level skip functions skip void?

JV(val1: auto const; val2: auto const; val3: auto const; val4: auto const; val5: auto const; val6: auto const; val7: auto const; val8: auto const; val9: auto const; val10: auto const)

JV returns json::JsonValue ?

argument

argument type

val1

auto const

val2

auto const

val3

auto const

val4

auto const

val5

auto const

val6

auto const

val7

auto const

val8

auto const

val9

auto const

val10

auto const

skip functions skip void? we only need to handle it as we are writing out, reading handles it at the enum level skip functions skip void?

21.4. Uncategorized

operator ?[](a: JsonValue const? const ==const; key: string const)

?[] returns json::JsonValue ? const

argument

argument type

a

json::JsonValue const? const!

key

string const

Returns the value of the index in the JSON array, if it exists.

operator ?[](a: JsonValue? ==const; key: string const)

?[] returns json::JsonValue ?

argument

argument type

a

json::JsonValue ?!

key

string const

Returns the value of the index in the JSON array, if it exists.

operator ?.(a: JsonValue const? const ==const; key: string const)

?. returns json::JsonValue ? const

argument

argument type

a

json::JsonValue const? const!

key

string const

Returns the value of the key in the JSON object, if it exists.

operator ?.(a: JsonValue? ==const; key: string const)

?. returns json::JsonValue ?

argument

argument type

a

json::JsonValue ?!

key

string const

Returns the value of the key in the JSON object, if it exists.

operator ?[](a: JsonValue const? const ==const; idx: int const)

?[] returns json::JsonValue ? const

argument

argument type

a

json::JsonValue const? const!

idx

int const

Returns the value of the index in the JSON array, if it exists.

operator ?[](a: JsonValue? ==const; idx: int const)

?[] returns json::JsonValue ?

argument

argument type

a

json::JsonValue ?!

idx

int const

Returns the value of the index in the JSON array, if it exists.

operator ??(a: JsonValue const? const; val: double const)

?? returns double const

argument

argument type

a

json::JsonValue const? const

val

double const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ??(a: JsonValue const? const; val: float const)

?? returns float const

argument

argument type

a

json::JsonValue const? const

val

float const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ??(a: JsonValue const? const; val: int8 const)

?? returns int8 const

argument

argument type

a

json::JsonValue const? const

val

int8 const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ??(a: JsonValue const? const; val: int16 const)

?? returns int16 const

argument

argument type

a

json::JsonValue const? const

val

int16 const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ??(a: JsonValue const? const; val: int const)

?? returns int const

argument

argument type

a

json::JsonValue const? const

val

int const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ??(a: JsonValue const? const; val: int64 const)

?? returns int64 const

argument

argument type

a

json::JsonValue const? const

val

int64 const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ??(a: JsonValue const? const; val: uint8 const)

?? returns uint8 const

argument

argument type

a

json::JsonValue const? const

val

uint8 const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ??(a: JsonValue const? const; val: uint16 const)

?? returns uint16 const

argument

argument type

a

json::JsonValue const? const

val

uint16 const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ??(a: JsonValue const? const; val: uint const)

?? returns uint const

argument

argument type

a

json::JsonValue const? const

val

uint const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ??(a: JsonValue const? const; val: uint64 const)

?? returns uint64 const

argument

argument type

a

json::JsonValue const? const

val

uint64 const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ??(a: JsonValue const? const; val: bool const)

?? returns bool const

argument

argument type

a

json::JsonValue const? const

val

bool const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ??(a: JsonValue const? const; val: string const)

?? returns string const

argument

argument type

a

json::JsonValue const? const

val

string const

Returns the value of the JSON object, if it exists, otherwise returns the default value.

operator ?.`value(a: JsonValue const? const ==const)

?.`value returns JsValue ?

argument

argument type

a

json::JsonValue const? const!

Returns the value of the JSON object, if it exists.

operator ?.`value(a: JsonValue? ==const)

?.`value returns JsValue ?

argument

argument type

a

json::JsonValue ?!

Returns the value of the JSON object, if it exists.

parse_json_annotation(name: string const; 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>>> const)

parse_json_annotation returns json_boost::JsonFieldState

argument

argument type

name

string const

annotation

array<tuple<name:string;data: RttiValue >> const

parse structure field annotations to deterimine JSON serialization options.