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.

  1. bool opEquals(JSONValue rhs)
  2. bool opEquals(JSONValue rhs)
    struct JSONValue
    const @nogc nothrow pure @trusted
    bool
    opEquals
    (
    ref const JSONValue rhs
    )

Return Value

Type: bool

whether this JSONValue is equal to rhs

Examples

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}`)));

Meta