Uploaded image for project: 'Johnzon'
  1. Johnzon
  2. JOHNZON-122

JSONP spec compliance: JsonNumber equality not spec compliant

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0.0
    • 1.1.2
    • None
    • None

    Description

      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
      

      [1] http://docs.oracle.com/javaee/7/api/javax/json/JsonNumber.html#equals-java.lang.Object-

      Attachments

        Activity

          People

            romain.manni-bucau Romain Manni-Bucau
            SvetlinZarev Svetlin Zarev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: