View source code Display the source code in std/json.d from which this page was generated on github. 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.

Function std.json.JSONValue.opIndexAssign

Operator sets value for element of JSON object by key

If JSON value is null, then operator initializes it with object and then

sets value for it.

Throws JSONException if type is not JSON_TYPE.OBJECT

or JSON_TYPE.NULL.

Prototype

void opIndexAssign(T)(
  T value,
  string key
) pure;

Example

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


Example

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


Example

JSONValue j = [ "language": "D", "author": "walter" ];
string a = ("author" in j).str;


Authors

Jeremie Pelletier, David Herberth

License

Boost License 1.0.

Comments