Array-Größe mit jsonpath Ausdruck - Stefan Goessner JsonPath

Ich habe ein problem mit der Suche nach einem array oder einer Liste der Größe mit Stefan Goessner ist JsonPath. Ich bin mit der version json-Pfad-2.0.0.

Meine jsonpath Ausdruck ist $.orders.length - und JSON sieht wie folgt aus:

JS:

{
  "orders" : [
    ...
  ]
}

Seines Scheiterns mit der folgenden Fehlermeldung:

com.jayway.jsonpath.PathNotFoundException: Property ['length'] not found in path $['orders']

Und ich habe versucht, mit $.orders.length() auch das wird wieder scheitern mit die folgende Fehlermeldung:

com.jayway.jsonpath.PathNotFoundException: Property ['length()'] not found in path $['orders']

Mich bitte vorschlagen, wie man die Länge des array mit Goessner ist JsonPath Ausdruck.

[BEARBEITEN] Folgende ist, wie ich bin Erlangung der Konfiguration:

    com.jayway.jsonpath.Configuration conf = com.jayway.jsonpath.Configuration.defaultConfiguration().addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL);
    DocumentContext documentContext = JsonPath.using(conf).parse(orderJson);
    Object val = documentContext.read(jsonPathExpression);
Schreibe einen Kommentar