The OpenD Programming Language

JSONValue

JSON value node

Constructors

this
this(T arg)

Constructor for JSONValue. If arg is a JSONValue its value and type will be copied to the new JSONValue. Note that this is a shallow copy: if type is JSONType.object or JSONType.array then only the reference to the data will be copied. Otherwise, arg must be implicitly convertible to one of the following types: typeof(null), string, ulong, long, double, an associative array V[K] for any V and K i.e. a JSON object, any array or bool. The type will be set accordingly.

Members

Functions

opApply
int opApply(int delegate(size_t index, ref JSONValue) dg)

Implements the foreach opApply interface for json arrays.

opApply
int opApply(int delegate(string key, ref JSONValue) dg)

Implements the foreach opApply interface for json objects.

opBinaryRight
inout(JSONValue)* opBinaryRight(string k)

Provides support for the in operator.

opEquals
bool opEquals(JSONValue rhs)
opIndex
inout(JSONValue) opIndex(size_t i)

Array syntax for JSON arrays.

opIndex
inout(JSONValue) opIndex(string k)

Hash syntax for JSON objects.

opIndexAssign
void opIndexAssign(T value, string key)
void opIndexAssign(T arg, size_t i)

Provides support for index assignments, which sets the corresponding value of the JSON object's key field to value.

toPrettyString
void toPrettyString(Out sink, JSONOptions options)
toPrettyString
string toPrettyString(JSONOptions options)

Implicitly calls toJSON on this JSONValue, like toString, but also passes true as pretty argument.

toString
string toString(JSONOptions options)

Implicitly calls toJSON on this JSONValue.

toString
void toString(Out sink, JSONOptions options)

Manifest constants

emptyArray
enum emptyArray;

An enum value that can be used to obtain a JSONValue representing an empty JSON array.

emptyObject
enum emptyObject;

An enum value that can be used to obtain a JSONValue representing an empty JSON object.

Properties

array
inout(JSONValue[]) array [@property getter]
JSONValue[] array [@property setter]

Value getter/setter for JSONType.array.

arrayNoRef
inout(JSONValue[]) arrayNoRef [@property getter]

Value getter for JSONType.array. Unlike array, this retrieves the array by value and can be used in @safe code.

boolean
bool boolean [@property getter]
bool boolean [@property setter]

Value getter/setter for boolean stored in JSON.

floating
double floating [@property getter]
double floating [@property setter]

Value getter/setter for JSONType.float_. Note that despite the name, this is a 64-bit double, not a 32-bit float.

get
inout(T) get [@property getter]

A convenience getter that returns this JSONValue as the specified D type. Note: Only numeric types, bool, string, JSONValue[string], and JSONValue[] types are accepted

integer
long integer [@property getter]
long integer [@property setter]

Value getter/setter for JSONType.integer.

isNull
bool isNull [@property getter]

Test whether the type is JSONType.null_

object
inout(JSONValue[string]) object [@property getter]
JSONValue[string] object [@property setter]

Value getter/setter for JSONType.object.

objectNoRef
inout(JSONValue[string]) objectNoRef [@property getter]

Value getter for JSONType.object. Unlike object, this retrieves the object by value and can be used in @safe code.

str
string str [@property getter]
string str [@property setter]

Value getter/setter for JSONType.string.

type
JSONType type [@property getter]

Returns the JSONType of the value stored in this structure.

uinteger
ulong uinteger [@property getter]
ulong uinteger [@property setter]

Value getter/setter for JSONType.uinteger.

Meta