Struct 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.
Constructors
Name Description
this
(__param_0)
Constructor for a JSON object.
this
(value)
Converts a std.json.JSONValue object to a vibe Json object.
Properties
Name Type Description
byIndexValue
[get]
std . range . ZipShortest !(1,std.range.iota!(int,ulong).iota(int,ulong).Result,vibe.data.json.Json[])
Iterates over all index/value pairs of an array.
emptyArray
[get]
Json
New JSON value of Type.Array
emptyObject
[get]
Json
New JSON value of Type.Object
get
[get]
inout ( T )
Converts the JSON value to the corresponding D type - types must match exactly.
length
[get]
ulong
Returns the number of entries of string, array or object typed JSON values.
opt
[set]
const ( T )
Returns the native type for this JSON if it matches the current runtime type.
to
[get]
inout ( T )
Converts the JSON value to the corresponding D type - types are converted as necessary.
type
[get]
Json . Type
The current type id of this JSON object.
typeId
[get]
Json . Type
Returns the type id corresponding to the given D type.
undefined
[get]
Json
New JSON value of Type.Undefined
Methods
Name Description
appendArrayElement
(element)
The append operator will append arrays. This method always appends it's argument as an array element, so nested arrays can be created.
byKeyValue
()
Iterates over all key/value pairs of an object.
byValue
()
Iterates over all values of an object or array.
clone
()
Clones a JSON value recursively.
opApply
(del)
Allows foreach iterating over JSON objects and arrays.
opAssign
(v)
Allows assignment of D values to a JSON value.
opBinary
(other)
Performs binary operations between JSON values.
opBinaryRight
(other)
Performs binary operations between JSON values.
opBinaryRight
(other)
Checks wheter a particular key is set and returns a pointer to it.
opCast
()
Converts this Json object to a std.json.JSONValue object
opCast
()
Converts the JSON value to the corresponding D type - types must match exactly.
opCmp
(other)
Compares two JSON values.
opEquals
(other)
Compares two JSON values for equality.
opIndex
(idx)
Allows direct indexing of array typed JSON values.
opIndex
(key)
Allows direct indexing of object typed JSON values using a string as
the key.
opOpAssign
(other)
Performs binary operations between JSON values.
opSlice
()
Returns a slice of a JSON array.
opSlice
(from, to)
opUnary
()
Performs unary operations on the JSON value.
remove
(item)
Allows removal of values from Type.Object Json objects.
toPrettyString
(level)
Returns the JSON object as a "pretty" string.
toString
()
Returns the JSON object as a string.
Enums
Name Description
Type
Represents the run time type of a JSON value.
Authors
Sönke Ludwig
Copyright
© 2012-2015 Sönke Ludwig
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.