Get field from JsonPath in java

How to get a field from a: b: c: d: f: 1.0 property via JsonPath?

"a:b:c:d:f:1.0" : {
    "field" : "field"}

I tried with a: b: c: d: f: 1.0.field, but it returns an invalid path.

+4
source share
2 answers

Please check the syntax above. You missed {and }surrounding the object.

Colon is :used in JSON to separate value pairs and the period is .also not allowed for names.

Assuming a JSON object as:

{
  "object" : {
    "field" : "field"}
}

You can get the value by expression $.object

When using JsonPath you can get the field through JsonPath.read([json_object], [expression])

0
source

I got the field using the following code

$.['a:b:c:d:f:1.0'].field

0

All Articles