johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Svetlin Zarev (JIRA)" <>
Subject [jira] [Created] (JOHNZON-122) JSONP spec compliance: JsonNumber equality not spec compliant
Date Mon, 05 Jun 2017 12:34:04 GMT
Svetlin Zarev created JOHNZON-122:

             Summary: JSONP spec compliance: JsonNumber equality not spec compliant
                 Key: JOHNZON-122
             Project: Johnzon
          Issue Type: Bug
    Affects Versions: 1.0.0
            Reporter: Svetlin Zarev

According to the JSONP spec:

Compares the specified object with this JsonNumber object for equality. Returns true if and
only if the type of the specified object is also JsonNumber and their bigDecimalValue() objects
are equal

yet johnzon considers "unequal" values to be equal

Sample application:
public final class Main {
    public static void main(String[] args) {
        JsonNumber a = Json.createObjectBuilder().add("a", 1).build().getJsonNumber("a");
        JsonNumber b = Json.createObjectBuilder().add("b", 1.1).build().getJsonNumber("b");

        System.out.println("EQUALS: " + a.equals(b));
        System.out.println("BigDecimal EQUALS: " + a.bigDecimalValue().equals(b.bigDecimalValue()));

Actual output:
EQUALS: true
BigDecimal EQUALS: false

Expected output:
EQUALS: false
BigDecimal EQUALS: false


This message was sent by Atlassian JIRA

View raw message