Json

Represents a single JSON value.

Json values can have one of the types defined in the Json.Type enum. They behave mostly like values in ECMA script in the way that you can transparently perform operations on them. However, strict typechecking is done, so that operations between differently typed JSON values will throw a JSONException. Additionally, an explicit cast or using get!() or to!() is required to convert a JSON value to the corresponding static D type.

struct Json {}

Constructors

this
this(typeof(null) )
this(bool v)
this(byte v)
this(ubyte v)
this(short v)
this(ushort v)
this(int v)
this(uint v)
this(long v)
this(double v)
this(string v)
this(Json[] v)
this(Json[string] v)

Constructor for a JSON object.

Members

Aliases

opDollar
alias opDollar = length
Undocumented in source.

Enums

Type
enum Type

Represents the run time type of a JSON value.

Functions

appendArrayElement
void appendArrayElement(Json element)

The append operator will append arrays. This method always appends it's argument as an array element, so nested arrays can be created.

clone
Json clone()
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref Json obj) del)
int opApply(int delegate(ref const Json obj) del)
int opApply(int delegate(ref size_t idx, ref Json obj) del)
int opApply(int delegate(ref size_t idx, ref const Json obj) del)
int opApply(int delegate(ref string idx, ref Json obj) del)
int opApply(int delegate(ref string idx, ref const Json obj) del)

Allows foreach iterating over JSON objects and arrays.

opAssign
Json opAssign(Json v)
void opAssign(typeof(null) )
bool opAssign(bool v)
int opAssign(int v)
long opAssign(long v)
double opAssign(double v)
string opAssign(string v)
Json[] opAssign(Json[] v)
Json[string] opAssign(Json[string] v)

Allows assignment of D values to a JSON value.

opBinary
Json opBinary(const(Json) other)
Json opBinary(Json other)
Json opBinary(bool other)
Json opBinary(long other)
Json opBinary(double other)
Json opBinary(string other)
Json opBinary(Json[] other)
opBinaryRight
Json opBinaryRight(bool other)
Json opBinaryRight(long other)
Json opBinaryRight(double other)
Json opBinaryRight(string other)
inout(Json)* opBinaryRight(string other)
Json opBinaryRight(Json[] other)

Performs binary operations between JSON values.

opCast
inout(T) opCast()

Converts the JSON value to the corresponding D type - types must match exactly.

opCmp
int opCmp(Json other)

Compares two JSON values.

opEquals
bool opEquals(Json other)
bool opEquals(typeof(null) )
bool opEquals(bool v)
bool opEquals(long v)
bool opEquals(double v)
bool opEquals(string v)

Compares two JSON values for equality.

opIndex
inout(Json) opIndex(size_t idx)

Allows direct indexing of array typed JSON values.

opIndex
const(Json) opIndex(string key)
Json opIndex(string key)

Allows direct indexing of object typed JSON values using a string as the key.

opOpAssign
void opOpAssign(Json other)
void opOpAssign(T other)

Performs binary operations between JSON values.

opSlice
inout(Json[]) opSlice()

Returns a slice of a JSON array.

opSlice
inout(Json[]) opSlice(size_t from, size_t to)
opUnary
Json opUnary()

Performs unary operations on the JSON value.

remove
void remove(string item)

Allows removal of values from Type.Object Json objects.

toPrettyString
string toPrettyString(int level)

Returns the JSON object as a "pretty" string.

toString
string toString()

Returns the JSON object as a string.

Properties

emptyArray
Json emptyArray [@property getter]

New JSON value of Type.Array

emptyObject
Json emptyObject [@property getter]

New JSON value of Type.Object

get
inout(T) get [@property getter]

Converts the JSON value to the corresponding D type - types must match exactly.

length
size_t length [@property getter]

Returns the number of entries of string, array or object typed JSON values.

opDispatch
const(Json) opDispatch [@property getter]
Json opDispatch [@property getter]

Allows to access existing fields of a JSON object using dot syntax.

opt
const(T) opt [@property setter]
T opt [@property setter]

Returns the native type for this JSON if it matches the current runtime type.

to
inout(T) to [@property getter]

Converts the JSON value to the corresponding D type - types are converted as necessary.

type
Type type [@property getter]

The current type id of this JSON object.

typeId
Type typeId [@property getter]

Returns the type id corresponding to the given D type.

undefined
Json undefined [@property getter]

New JSON value of Type.Undefined

Variables

line
int line;
Undocumented in source.

Meta