jsonwrap

Undocumented in source.

Members

Aliases

JSAB
alias JSAB = JsonArrayBuilder
Undocumented in source.
JSOB
alias JSOB = JsonObjectBuilder
Undocumented in source.
get
deprecated alias get = jsonwrap.safe
Undocumented in source.

Functions

JsonArrayBuilder
JSONValue JsonArrayBuilder(T vals)

You can build a json array with JsonArrayBuilder("first", 32, "another_element", 2, 23.4, JsonObjectBuilder(...));

JsonObjectBuilder
JSONValue JsonObjectBuilder(T vals)

You can build a json object with JsonObjectBuilder("key", 32, "another_key", "hello", "subobject", JsonObjectBuilder(...));

append
JSONValue append(JSONValue json, string path, T value)

Append value to array. Array is created if not exists.

as
SafeValue!T as(JSONValue json, string path, T defaultValue)

It allows you to read deep values inside a json. If possibile it converts value to type T.

as
SafeValue!(typeof(null)) as(JSONValue json, string path)

Shortcut. You can write as!null instead of as!(typeof(null))

exists
bool exists(JSONValue json, string path)

Check if a field exists or not

parse
JSONValue parse(JSONValue json, string data)

Parse a string

put
JSONValue put(JSONValue json, string path, T value)

Write a value. It creates missing objects and array (also missing elements)

read
T read(JSONValue json, string path)

Works like safe but return T instead of SafeValue!T and throw an exception if something goes wrong (can't convert value or can't find key)

remove
JSONValue remove(JSONValue json, string path)

Remove a field (if it exists). It returns the object itself

safe
SafeValue!T safe(JSONValue json, string path, T defaultValue)

Works like as!T but it doesn't convert between types.

safe
SafeValue!(typeof(null)) safe(JSONValue json, string path)

Shortcut. You can write safe!null instead of safe!(typeof(null))

Structs

SafeValue
struct SafeValue(T)

A simple struct. It is returned by .safe and .as functions

Meta