-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Hello!
I've encountered what I believe could be a bug when evaluating some JSONata:
I have the following JSON:
[
{
"value": {
"Name": "Cell1",
"Product": "Product1"
}
},
{
"value": {
"Name": "Cell2",
"Product": "Product2"
}
}
]I am attempting to run the following JSONata expression against it:
*[value.Product = 'Product1']
I expect the result to be
{
"value": {
"Name": "Cell1",
"Product": "Product1"
}
}But instead I receive null.
Changing the expression to the following does produce the correct response.
**[value.Product = 'Product1']
I've verified that I do receive that expected bit of JSON on https://try.jsonata.org/.
This is what my code looks like:
import static com.dashjoin.jsonata.Jsonata.jsonata;
import com.fasterxml.jackson.databind.ObjectMapper;
public class Main {
public static void main(String[] args) throws Throwable {
String json = "[\n" +
" {\n" +
" \"value\": {\n" +
" \"Name\": \"Cell1\",\n" +
" \"Product\": \"Product1\"\n" +
" }\n" +
" },\n" +
" {\n" +
" \"value\": {\n" +
" \"Name\": \"Cell2\",\n" +
" \"Product\": \"Product2\"\n" +
" }\n" +
" }\n" +
"]";
var data = new ObjectMapper().readValue(json, Object.class);
var expression = jsonata("*[value.Product = 'Product1']");
var result = expression.evaluate(data); // Expecting the first object in the array, but get null instead
var expression2 = jsonata("**[value.Product = 'Product1']");
var result2 = expression2.evaluate(data); // Received the first object in the array as expected
}
}I apologize if this isn't the right avenue or format for a bug report, or if there is something trivial that I've missed.
Thank you in advance for any help/guidance :)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working