Error in a!jsonPath example

Hi, I'm getting some unexpected results with the a!jsonPath function when working with 2 dimensional json arrays.

For my expression:

with(
local!srcJson: "[[1,2],[4,5]]",
a!jsonPath(
local!srcJson,
"[*].[0]"
)
)

The expected result is [1,4] (the first element from each of the first level array dimensions).

Appian 17.4 is returning [1,2] which is incorrect.

Has anyone had other issues with the a!jsonPath function not returning the required results?

Can anyone suggest a jsonPath expression which would return the first element for the first level array dimension?

  Discussion posts and replies are publicly visible

  • This does look like a bug. I took your JSON and used an on-line expression evaluation tool and used the jsonPath expression "$.[*].[1]" which returns [2,5] which appears to be what you're looking for. An option would be to write as follows:

    with(
    local!srcJson: "[[1,2],[4,5]]",
    {
    a!jsonPath(
    local!srcJson,
    "$.[0].[1]"
    ),
    a!jsonPath(
    local!srcJson,
    "$.[1].[1]"
    )
    }
    )

    ...but it's not very satisfactory.
  • ...and a more generic form would be to loop on the number of items in the first array in order to extract the array items as follows:

    with(
    local!srcJson: "[[1,2],[4,5]]",
    a!forEach(
    items: fn!enumerate(
    fn!length(
    a!fromJson(
    a!jsonPath(
    local!srcJson,
    "$.[0]"
    )
    )
    )
    ),
    expression: a!jsonPath(
    local!srcJson,
    fn!concat(
    "$.[",
    fv!item,
    "].[1]"
    )
    )
    )
    )

    ...but again, not very satisfactory when your original method should work!