You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have the following json:
{
"Type": "RRR",
"TypeNames": [
{
"Type": "AAA",
"Name":"Test1"
},
{
"Type" : "BBB",
"Name":"Test2"
}
]
}
I want to get the name where type="BBB"
In the following function I expect to get 1 results but I'm getting 3:
tree= the above json.
Hi,
I have the following json:
{
"Type": "RRR",
"TypeNames": [
{
"Type": "AAA",
"Name":"Test1"
},
{
"Type" : "BBB",
"Name":"Test2"
}
]
}
I want to get the name where type="BBB"
In the following function I expect to get 1 results but I'm getting 3:
tree= the above json.
public static void testArrayCondition(String tree) {
String prop = "$.TypeNames[?(@.Type == 'BBB')].Name";
DocumentContext ctxt = JsonPath.using(TypedObjectJsonInfo.configuration).parse(tree);
JsonPathLocation listen = new JsonPathLocation(prop, ctxt);
ReadContext readCtxt = ctxt.withListeners(listen);
try {
readCtxt.read(prop);
} catch (Exception e) {
System.out.println("error" + e);
}
int numResults = listen.getCounter();
System.out.println("numResults" + numResults);
}
The text was updated successfully, but these errors were encountered: