vibe.d beta banner
get vibe.d
0.10.1

Asynchronous I/O that doesn’t get in your way, written in D

Json.opBinaryRight - multiple declarations

Function Json.opBinaryRight

Performs binary operations between JSON values.

Json opBinaryRight(string op) (
  bool other
) const;

Json opBinaryRight(string op) (
  long other
) const @trusted;

Json opBinaryRight(string op) (
  BigInt other
) const @trusted;

Json opBinaryRight(string op) (
  double other
) const;

Json opBinaryRight(string op) (
  string other
) const @trusted
if (op == "~");

Json opBinaryRight(string op) (
  Json[] other
) @trusted;

The two JSON values must be of the same run time type or a JSONException will be thrown. Only the operations listed are allowed for each of the types.

Null
none
Bool
&&, ||
Int
+, -, *, /, %
Float
+, -, *, /, %
String
~
Array
~
Object
in

Function Json.opBinaryRight

Checks wheter a particular key is set and returns a pointer to it.

inout inout(Json)* opBinaryRight(string op) (
  string other
) @trusted
if (op == "in");

For field that don't exist or have a type of Type.undefined, the in operator will return null.

Example

auto j = Json.emptyObject;
j["a"] = "foo";
j["b"] = Json.undefined;

assert("a" in j);
assert(("a" in j).get!string == "foo");
assert("b" !in j);
assert("c" !in j);

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.