You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by "Romain Manni-Bucau (JIRA)" <ji...@apache.org> on 2017/06/05 12:50:04 UTC

[jira] [Resolved] (JOHNZON-122) JSONP spec compliance: JsonNumber equality not spec compliant

     [ https://issues.apache.org/jira/browse/JOHNZON-122?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Romain Manni-Bucau resolved JOHNZON-122.
----------------------------------------
       Resolution: Fixed
         Assignee: Romain Manni-Bucau
    Fix Version/s: 1.1.2

> JSONP spec compliance: JsonNumber equality not spec compliant
> -------------------------------------------------------------
>
>                 Key: JOHNZON-122
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-122
>             Project: Johnzon
>          Issue Type: Bug
>    Affects Versions: 1.0.0
>            Reporter: Svetlin Zarev
>            Assignee: Romain Manni-Bucau
>             Fix For: 1.1.2
>
>
> According to the JSONP spec:
> {code}
> 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
> {code}
> yet johnzon considers "unequal" values to be equal
> Sample application:
> {code}
> 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()));
>     }
> }
> {code}
> Actual output:
> {code}
> EQUALS: true
> BigDecimal EQUALS: false
> {code}
> Expected output:
> {code}
> EQUALS: false
> BigDecimal EQUALS: false
> {code}
> [1] http://docs.oracle.com/javaee/7/api/javax/json/JsonNumber.html#equals-java.lang.Object-



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)