Search code examples
jsonrestetltalendjsonpath

Talend - tRESTClient --> tExtractJSONField - json path query


I have this workflow in Talend: enter image description here

I send a req to: https://api.coinbase.com/v2/currencies

And get this JSON responce:

{
  "data": [
    {
      "id": "AED",
      "name": "United Arab Emirates Dirham",
      "min_size": "0.01000000"
    },
    {
      "id": "AFN",
      "name": "Afghan Afghani",
      "min_size": "0.01000000"
    },
    {
      "id": "ZWL",
      "name": "Zimbabwean Dollar",
      "min_size": "0.01000000"
    }
  ]
}

However tExtractJSONField does not parse the JSON.

I can not get the paths and options right. Any help would be appreciated.

enter image description here

What are the right Jsonpath query and mapping table to extract all id's from JSON responce.


Solution

  • In Loop Jsonpath query, you need to use:

    $.data[*]
    

    And in the json query for each column, you put the corresponding field name: id, name, min_size. enter image description here

    enter image description here

    Warning: tRESTClient has a setting to convert json to xml, which is enabled by default. You need to go to advanced settings and uncheck "convert response to DOM document".