[Solved] How to extract JSON values that does not have attribute names?


Analysis

XPath can’t read unnamed attributes. It will always result in an exception. If you want to get the values, you need to use JsonPath.

Solution

Even then, it makes sense to add surrounding brackets, otherwise the first level will be consumed as well:

[
    {
 "A1":{
       "name":"Ad hoc",
       "projectId":0
      },
 "X2":{
       "name":"BBB",
       "projectId":101
        },
 "AB":{
       "name":"CCC",
       "projectId":102
        },
 "recordsCount":3
    }
]

You can try the correct query on jsonpath.com. For me (with the additional brackets) the path $.* worked.

To extract the values, you need to use a tExtractJSONFields component in Talend if using a file or REST request.

A valid JSON query could be easily [0] for the field with alphanumeric identifiers.

solved How to extract JSON values that does not have attribute names?