Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

std.json

JavaScript Object Notation

License:
Boost License 1.0.

Authors:
Jeremie Pelletier

References:
http://json.org/

Source:
std/json.d

enum JSON_TYPE;
JSON type enumeration

STRING
INTEGER
Indicates the type of a JSONValue.

UINTEGER
FLOAT
OBJECT
ARRAY
TRUE
FALSE
NULL
integers > 2^63-1

struct JSONValue;
JSON value node

string str;
Value when type is JSON_TYPE.STRING

long integer;
Value when type is JSON_TYPE.INTEGER

ulong uinteger;
Value when type is JSON_TYPE.UINTEGER

real floating;
Value when type is JSON_TYPE.FLOAT

JSONValue[string] object;
Value when type is JSON_TYPE.OBJECT

JSONValue[] array;
Value when type is JSON_TYPE.ARRAY

JSON_TYPE type;
Specifies the type of the value stored in this structure.

ref JSONValue opIndex(size_t i);
array syntax for json arrays

ref JSONValue opIndex(string k);
hash syntax for json objects

JSONValue parseJSON(T)(T json, int maxDepth = -1);
Parses a serialized string and returns a tree of JSON values.

string toJSON(in JSONValue* root);
Takes a tree of JSON values and returns the serialized string.

class JSONException: object.Exception;
Exception thrown on JSON errors