Json

Parse json text into a set of inter-related structures.

Constructors

this
this()

Construct a json instance, with a default value of null

Members

Aliases

Attribute
alias Attribute = NameValue*
Undocumented in source.
Composite
alias Composite = JsonObject*
Undocumented in source.
Value
alias Value = JsonValue*

use these types for external references

Enums

Type
enum Type

enumerates the seven acceptable JSON value types

Functions

array
Value array(...)

Create an array of values

object
Value object(Attribute[] set)

Create a composite from zero or more pairs, and return as a value

pair
Attribute pair(const(T)[] name, Value value)

Create an attribute/value pair, where value defaults to null

parse
Value parse(const(T)[] json)

Parse the given text and return a resultant Value type. Also sets the document value.

toString
const(T)[] toString(const(T)[] space, int decimals)

Return a text representation of this document

value
Value value()

Returns the root value of this document

value
Value value(Value v)

Set the root value of this document

value
Value value(const(T)[] v)

Create a text value

value
Value value(bool v)

Create a boolean value

value
Value value(double v)

Create a numeric value

value
Value value(Value[] vals)

Create a single Value from an array of Values

Structs

JsonObject
struct JsonObject

Represents a single json Object (a composite of named attribute/value pairs).

JsonValue
struct JsonValue

Represents a json value that is one of the seven types specified via the Json.Type enum

NameValue
struct NameValue

Represents an attribute/value pair. Aliased as Attribute

Examples

with (new Json!(char))
{
    root = object
        (
         pair ("edgar", value("friendly")),
         pair ("count", value(11.5)),
         pair ("array", value(array(1, 2)))
        );

    auto value = toString();
    test (value == `{"edgar":"friendly","count":11.5,"array":[1, 2]}`, value);
}

Meta