Skip to content

Sort expression ^() throws ClassCastException with mixed Integer/Double values #97

@85C77EF3-E4C7-4251-A987-02CB8DD42971

Description

The sort comparator crashes when sort key values are a mix of Integer and Double. This commonly happens with $round(), which returns Integer for whole-number results and Double for fractional ones.

Reproduction:

[{"name": "a", "value": 12}, {"name": "b", "value": 5.9}, {"name": "c", "value": 8}] ^(<value)

Result:

java.lang.ClassCastException: class java.lang.Double cannot be cast to class java.lang.Integer
  at java.lang.Integer.compareTo(Integer.java:77)
  at com.dashjoin.jsonata.Jsonata$4.compare(Jsonata.java:1383)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions