.. _std_json: .. highlight:: d std.json -------- .. c:namespace:: std.json Module entries: :class:`JSONValue`, :func:`__jv` .. class:: JSONValue This type represents a JSON value. Example:: auto value = JSONValue([("Hello", JSONValue("World"))]); assert(value.toString == "{\"Hello\": \"World\"}"); assert(JSONValue.parse("{\"Hello\": \"World\"}").toString == "{\"Hello\": \"World\"}"); .. method:: parse(str) `JSONValue parse(string str)` Parse a JSON value from a string. .. method:: loadFile(file) `JSONValue loadFile(string file)` Load a JSON value from a file. .. method:: integer() `int integer()` Interprets a JSON value as an integer. .. method:: str() `string str()` Interprets a JSON value as a string. .. method:: boolean() `bool boolean()` Interprets a JSON value as a boolean. .. method:: array() `JSONValue[] array()` Interprets a JSON value as an array. .. method:: object() `(string key, JSONValue value)[] object()` Interprets a JSON value as an object. .. method:: isArray() `bool isArray()` Returns true if the JSON value is an array. .. method:: isObject() `bool isObject()` Returns true if the JSON value is an object. .. method:: get(key) `JSONValue get(string key)` Returns the JSON value for a key. .. method:: has(key) `bool has(string key)` Returns true if the JSON value, which must be an object, contains the key. .. method:: set(key, value) `void set(string key, JSONValue value)` Sets the given key to a value. .. method:: keys() `string[] keys()` Given the value is an object, returns an array of string keys. .. method:: toString() `string toString()` Converts a JSON value to a string. .. function:: __jv(arg) `JSONValue __jv((bool | int | JSONValue[] | string | (string key, JSONValue value)[] | JSONValue) arg)` TODO: document