-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An error occurred when convert empty array to an object in 1.8.5 #547
Comments
Additional Information. In "1.8.0 - 1.8.4" worked as expected. steps to reproduce
import jsonata from 'jsonata';
const data = [];
try {
const expression = jsonata('$${id:{"label":label,"value":value}}');
console.log(
`result => ${JSON.stringify(expression.evaluate(data), null, ' ')}`
);
} catch (err) {
console.log(`err => ${err.message}`);
} 1.8.0 - 1.8.4
1.8.5
|
kexuibm
added a commit
to kexuibm/jsonata
that referenced
this issue
Dec 10, 2021
kexuibm
added a commit
to kexuibm/jsonata
that referenced
this issue
Jan 4, 2022
kexuibm
added a commit
to kexuibm/jsonata
that referenced
this issue
Jan 4, 2022
kexuibm
added a commit
to kexuibm/jsonata
that referenced
this issue
Jan 5, 2022
kexuibm
added a commit
to kexuibm/jsonata
that referenced
this issue
Jan 5, 2022
andrew-coleman
pushed a commit
that referenced
this issue
Jan 6, 2022
Resolved by #555 |
Doesn't this warrant a new release? |
@asampal 1.8.6 was released today with this fix (among others) |
This was referenced Mar 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to convert an array of API responce to an object with JSONata.
in many cases it works very well.
(JSONata is very powerful)
However, I get an error when I convert an empty array in JSONata 1.8.5.
(in 1.7.0 work as expected)
steps to reproduce
I tried it with JSONata Exerciser.
array to object
It works in the following cases.
https://try.jsonata.org/uvEJnSWm-
jsonata:
$${id:{"label":label,"value":value}}
json:
result:
empty array
An error occurred when json was an empty array.
https://try.jsonata.org/r9UY9cPmx
(in 1.7.0 work as expected)
json:
result (1.8.5):
result (1.7.0):
workaround
The following query works even with an empty array
The text was updated successfully, but these errors were encountered: