The OpenD Programming Language

JSONValue.opIndexAssign

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

If the JSONValue is JSONType.null_, then this function initializes it with a JSON object and then performs the index assignment.

  1. void opIndexAssign(T value, string key)
    struct JSONValue
    void
    opIndexAssign
    (
    T
    )
    (
    auto ref T value
    ,
    string key
    )
  2. void opIndexAssign(T arg, size_t i)

Throws

JSONException if type is not JSONType.object or JSONType.null_.

Examples

JSONValue j = JSONValue( ["language": "D"] );
j["language"].str = "Perl";
assert( j["language"].str == "Perl" );
JSONValue j = JSONValue( ["Perl", "C"] );
j[1].str = "D";
assert( j[1].str == "D" );

Meta