Skip to content

[] On parent makes arrays on subitems also #290

Description

@ZeroWiggliness

Using [] to force a single item to an array also puts sub items into an array. This differs in fuctionality to the JSONata exerciser and thus not giving us the output we expect:

I simplified our problem:

Jsonata:
$.( { "items": orderItems.{ "itemId": itemId, "quantity": quantity.value, "code": quantity.unit }[] } )

Input:
{ "orderItems": [ { "itemId": "3fa85f64-5717-4562-b3fc-21234f66afa6", "quantity": { "value": 2, "unit": "EA" } }, { "itemId": "3fa85f64-5717-4562-b3fc-21235f66afa6", "quantity": { "value": 2, "unit": "EA" } } ] }

Expected Output:

{ "items": [ { "itemId": "3fa85f64-5717-4562-b3fc-21234f66afa6", "quantity": 2, "code": "EA" }, { "itemId": "3fa85f64-5717-4562-b3fc-21235f66afa6", "quantity": 2, "code": "EA" } ] }

Actual output:

{ "items" : [ { "itemId" : "3fa85f64-5717-4562-b3fc-21234f66afa6", "quantity" : [ 2 ], "code" : [ "EA" ] }, { "itemId" : "3fa85f64-5717-4562-b3fc-21235f66afa6", "quantity" : [ 2 ], "code" : [ "EA" ] } ] }

This is using Camel JSONata which is using 2.4.5 of this library for reference

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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