View source code
Display the source code in std/json.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aBugzilla issue.
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 usinglocal clone.
Function std.json.JSONValue.opEquals
Compare two JSONValues for equality
JSON arrays and objects are compared deeply. The order of object keys does not matter.
Floating point numbers are compared for exact equality, not approximal equality.
Different number types (unsigned, signed, and floating) will be compared by converting
them to a common type, in the same way that comparison of built-in D int
, uint
and
float
works.
Other than that, types must match exactly. Empty arrays are not equal to empty objects, and booleans are never equal to integers.
Returns
Example
assert(JSONValue(10) .opEquals(JSONValue(10.0)));
assert(JSONValue(10) != (JSONValue(10.5)));
assert(JSONValue(1) != JSONValue(true));
assert(JSONValue .emptyArray != JSONValue .emptyObject);
assert(parseJSON(`{"a": 1, "b": 2}`) .opEquals(parseJSON(`{"b": 2, "a": 1}`)));
Authors
Jeremie Pelletier, David Herberth
License
Copyright © 1999-2025 by the D Language Foundation | Page generated by ddox.