# tHTTPClient: configuration for retrieving specific data from a JSON array

This article lists configuration combinations for retrieving specific data from a JSON array using the Extract a sub-part of the response field and the Output key/value pairs option and the corresponding output. This article uses the following Job to retrieve and display data. The sub-elements of the element specified in the Extract a sub-part of the response field will be retrieved. If the sub-elements form an array, the component will generate one output record for each of the array elements.

Information noteNote: Behavior change: From Talend Studio v8.0.1-R2024-12 onwards, JSON arrays are parsed as arrays. In earlier versions, JSON arrays were returned as a single string with elements separated by line breaks (\n). If you have existing Jobs that rely on the previous behavior for single-element JSON arrays, you can restore the legacy output by setting the following system property to true:

```
org.talend.components.common.dssldictionary.DSSLDictionary.SINGLE_ELEMENT_NOT_ARRAY
```

This property is intended for backward compatibility; prefer updating Jobs to handle arrays where possible.

![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/thttpclient-schema-and-output-1.png)

The JSON array in the query response payload is given below.

```
[
  {
    "name": "Peter",
    "age": 40,
    "male": true,
    "addresses": {
       "city": "Nantes",
       "zip": "44000",
       "street": "bd prairie au duc"
    },
    "cars": [
       {"brand": "Ford", "model": "Transit", "km": 123456},
       {"brand": "Renault", "model": "Clio", "km": 87234}
    ]
  },
   {
    "name": "Emma",
    "age": 34,
    "male": true,
    "addresses": {
       "city": "Paris",
       "zip": "75000",
       "street": "bd Saint-Germain"
    },
    "cars": [
       {"brand": "Tesla", "model": "Model 3", "km": 63456},
       {"brand": "Ford", "model": "Mustang Mach-E", "km": 32543},
       {"brand": "Volkswagen", "model": "Golf 8", "km": 43876},
    ]
  }
]
```

The following figure shows the base configuration of the tHTTPClient component. ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/thttpclient-schema-and-output-e.png)

* Retrieving all the elements under the root element.

  * Configuration
    | Configuration item | Setting |
    | --- | --- |
    | Schema columns | <ul> <li><span>name</span>, type String</li> <li><span>age</span>, type Int</li> <li><span>address</span>, type String</li> </ul> |
    | Response body format | JSON |
    | Extract a sub-part of the response<br>field | Empty, . (a dot), or<br>.root<br><br>This configuration points to the root element of the JSON<br>array. |
  * Output ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/thttpclient-schema-and-output-a.png)

* Retrieving a sub-element under the root element.

  * Configuration
    | Configuration item | Setting |
    | --- | --- |
    | Schema columns | <ul> <li><span>name</span>, type String</li> <li><span>age</span>, type Int</li> <li><span>address</span>, type String</li> </ul> |
    | Response body format | JSON |
    | Extract a sub-part of the response<br>field | .root[1]<br><br>This configuration points to the second element under the root element<br>of the JSON array. Note that array element index begins from 0. |
  * Output ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/thttpclient-schema-and-output-b.png)

* Retrieving the information about *Emma*'s cars.

  * Configuration
    | Configuration item | Setting |
    | --- | --- |
    | Schema columns | <ul> <li><span>brand</span>, type String</li> <li><span>model</span>, type String</li> <li><span>km</span>, type Int</li> </ul> |
    | Response body format | JSON |
    | Extract a sub-part of the response<br>field | .root[1].cars<br><br>This configuration points to the *cars* element of<br>*Emma*, the second element under the root element. |
  * Output ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/thttpclient-schema-and-output-c.png)

* Retrieving the information about *Emma*'s cars with the values of the km elements larger than 40000.

  * Configuration
    | Configuration item | Setting |
    | --- | --- |
    | Schema columns | <ul> <li><span>brand</span>, type String</li> <li><span>model</span>, type String</li> <li><span>km</span>, type Int</li> </ul> |
    | Response body format | JSON |
    | Extract a sub-part of the response<br>field | .root[1].cars{.km&gt;40000}<br><br>This configuration points to the *cars* element of<br>*Emma* with the values of the km elements larger than<br>40000. |
  * Output ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/thttpclient-schema-and-output-d.png)

* Retrieving data using key/value pairs.

  Once the main data is extracted using Extract a sub-part of the response field, you can also extract values of specific elements to create flat records. To do so, select the Output key/value pairs option and add some name/value pairs in the table. For a name/value pair, *name* is the name of a schema column and *value* is an expression pointing to an element of the response. The expression can contain some DSSL selectors to retrieve values from the response of the HTTP query configured in the connector. In the following example, Extract a sub-part of the reponse holds a value of . (a dot) and the two records, *Peter* and *Emma*, will be looped.

  * Configuration
    | Configuration item | Setting |
    | --- | --- |
    | Schema columns | <ul> <li><span>name</span>, type String</li> <li><span>age</span>, type Int</li> <li><span>address1</span>, type String</li> <li><span>address2</span>, type String</li> <li><span>first_car_brand</span>, type String</li> </ul> |
    | Response body format | JSON |
    | Extract a sub-part of the response<br>field | . (a dot)<br><br>This configuration points to the *cars* element of<br>*Emma* with the values of the km elements larger than<br>40000. |
    | Output key/value pairs | Selected, with the name/values pairs shown in the following<br>figure. |

    ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/thttpclient-schema-and-output-f.png)
  * Output ![](https://help.qlik.com/talend/en-US/components/8.0/Resources/images/thttpclient-schema-and-output-g.png)