Skip to content

Null values from array indexing inside $map are dropped #35

Description

@myxzos

Package version: 0.6.2
Python version: 3.14.3

Evaluating the following data:

{
  "data": [
    [1, null, 3],
    [2, null, 4],
    [3, null, 5]
  ]
}

with the following expression:

[$map(data, function($row) { $row[1] })]

returns an empty array ([]) in jsonata-python, but it returns [null, null, null] in the JSONata Exerciser. This seems to be an issue when the inner items are arrays being indexed, but not when they are objects being accessed by property. For example, running the following script:

import json

from jsonata import Jsonata

data = json.loads('{ "data": [[null], [null], [null]] }')
expr = "[$map(data, function($row) { $row[0] })]"
result = Jsonata(expr).evaluate(data)
print(result)

data = json.loads('{ "data": [{ "key": null }, { "key": null }, { "key": null }] }')
expr = "[$map(data, function($row) { $row.key })]"
result = Jsonata(expr).evaluate(data)
print(result)

results in

[]
[None, None, None]

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions