<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Consuming REST API and extracting dynamic nested JSON fields in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Consuming-REST-API-and-extracting-dynamic-nested-JSON-fields/m-p/2244449#M30601</link>
    <description>&lt;P&gt;I am rather new to Talend, however I have a software developer background.&lt;/P&gt; 
&lt;P&gt;I have a project where I need to query Zendesk’s Rest API and store the information in AWS Redshift. So far I have pulled about 4 APIs into Redshift without much problem.&lt;/P&gt; 
&lt;P&gt;However, the object Ticket contains nested JSON elements and some elements (custom fields) are in a dynamic array of JSON objects, such as:&lt;/P&gt; 
&lt;PRE&gt;{
    "ticket": {
        "url": "https://{DOMAIN}.zendesk.com/api/v2/tickets/60335.json",
        "id": 99966685,
        "external_id": null,
        "via": {
            "channel": "web",
            "source": {
                "from": {},
                "to": {},
                "rel": null
            }
        },
        "created_at": "2019-02-26T18:05:35Z",
        "updated_at": "2019-03-06T18:02:13Z",
        "type": "incident",
        "subject": "Extract request",
        "raw_subject": "VExtract request",
        "description": "Long Text Here",
        "priority": "normal",
        "status": "pending",
        "recipient": null,
        "requester_id": 370109203834,
        "submitter_id": 370109203834,
        "assignee_id": 497118067,
        "organization_id": 21682736,
        "group_id": 20168737,
        "collaborator_ids": [
            497118067,
            540244256,
            13249116068
        ],
        "follower_ids": [
            497118067,
            540244256,
            13249116068
        ],
        "email_cc_ids": [],
        "forum_topic_id": null,
        "problem_id": null,
        "has_incidents": false,
        "is_public": true,
        "due_at": null,
        "tags": [
            "3___medium",
            "custom_extract",
            "custom_api",
            "extracts",
            "normal",
            "ts2",
            "wex"
        ],
        "custom_fields": [
            {
                "id": 22827487,
                "value": "custom_extract"
            },
            {
                "id": 22798946,
                "value": "extracts"
            },
            {
                "id": 21670316,
                "value": "3___medium"
            },
            ...
            {
                "id": 30046718,
                "value": null
            }
        ],
        "satisfaction_rating": {
            "score": "unoffered"
        },
        "sharing_agreement_ids": [],
        "fields": [
            {
                "id": 22827487,
                "value": "custom_extract"
            },
            {
                "id": 22798946,
                "value": "extracts"
            },
            ...
            {
                "id": 30046718,
                "value": null
            }
        ],
        "followup_ids": [],
        "ticket_form_id": 12345,
        "brand_id": 12345,
        "satisfaction_probability": null,
        "allow_channelback": false,
        "allow_attachments": true
    }
}&lt;/PRE&gt; 
&lt;P&gt;When I query the Ticket API I get a list of Tickets, so I already use tExtractJSONFields, using JsonPath, with a Loop JsonPath query "$.tickets[*]".&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;So my question is how to parse the list of JSON documents inside the element "custom_fields", so from this string.&lt;/P&gt; 
&lt;PRE&gt;[{"id":22827487,"value":"feature"},{"id":22798946,"value":"ap"},{"id":30046718,"value":"test"}]&lt;/PRE&gt; 
&lt;P&gt;to a row based approach, I also have to keep in mind, that these list is dynamic, meaning more custom fields could be later added.&lt;/P&gt; 
&lt;PRE&gt;id, value
22827487, "feature"
22798946,ap"
30046718,"test"&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 06:21:59 GMT</pubDate>
    <dc:creator>lgati</dc:creator>
    <dc:date>2024-11-16T06:21:59Z</dc:date>
    <item>
      <title>Consuming REST API and extracting dynamic nested JSON fields</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Consuming-REST-API-and-extracting-dynamic-nested-JSON-fields/m-p/2244449#M30601</link>
      <description>&lt;P&gt;I am rather new to Talend, however I have a software developer background.&lt;/P&gt; 
&lt;P&gt;I have a project where I need to query Zendesk’s Rest API and store the information in AWS Redshift. So far I have pulled about 4 APIs into Redshift without much problem.&lt;/P&gt; 
&lt;P&gt;However, the object Ticket contains nested JSON elements and some elements (custom fields) are in a dynamic array of JSON objects, such as:&lt;/P&gt; 
&lt;PRE&gt;{
    "ticket": {
        "url": "https://{DOMAIN}.zendesk.com/api/v2/tickets/60335.json",
        "id": 99966685,
        "external_id": null,
        "via": {
            "channel": "web",
            "source": {
                "from": {},
                "to": {},
                "rel": null
            }
        },
        "created_at": "2019-02-26T18:05:35Z",
        "updated_at": "2019-03-06T18:02:13Z",
        "type": "incident",
        "subject": "Extract request",
        "raw_subject": "VExtract request",
        "description": "Long Text Here",
        "priority": "normal",
        "status": "pending",
        "recipient": null,
        "requester_id": 370109203834,
        "submitter_id": 370109203834,
        "assignee_id": 497118067,
        "organization_id": 21682736,
        "group_id": 20168737,
        "collaborator_ids": [
            497118067,
            540244256,
            13249116068
        ],
        "follower_ids": [
            497118067,
            540244256,
            13249116068
        ],
        "email_cc_ids": [],
        "forum_topic_id": null,
        "problem_id": null,
        "has_incidents": false,
        "is_public": true,
        "due_at": null,
        "tags": [
            "3___medium",
            "custom_extract",
            "custom_api",
            "extracts",
            "normal",
            "ts2",
            "wex"
        ],
        "custom_fields": [
            {
                "id": 22827487,
                "value": "custom_extract"
            },
            {
                "id": 22798946,
                "value": "extracts"
            },
            {
                "id": 21670316,
                "value": "3___medium"
            },
            ...
            {
                "id": 30046718,
                "value": null
            }
        ],
        "satisfaction_rating": {
            "score": "unoffered"
        },
        "sharing_agreement_ids": [],
        "fields": [
            {
                "id": 22827487,
                "value": "custom_extract"
            },
            {
                "id": 22798946,
                "value": "extracts"
            },
            ...
            {
                "id": 30046718,
                "value": null
            }
        ],
        "followup_ids": [],
        "ticket_form_id": 12345,
        "brand_id": 12345,
        "satisfaction_probability": null,
        "allow_channelback": false,
        "allow_attachments": true
    }
}&lt;/PRE&gt; 
&lt;P&gt;When I query the Ticket API I get a list of Tickets, so I already use tExtractJSONFields, using JsonPath, with a Loop JsonPath query "$.tickets[*]".&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;So my question is how to parse the list of JSON documents inside the element "custom_fields", so from this string.&lt;/P&gt; 
&lt;PRE&gt;[{"id":22827487,"value":"feature"},{"id":22798946,"value":"ap"},{"id":30046718,"value":"test"}]&lt;/PRE&gt; 
&lt;P&gt;to a row based approach, I also have to keep in mind, that these list is dynamic, meaning more custom fields could be later added.&lt;/P&gt; 
&lt;PRE&gt;id, value
22827487, "feature"
22798946,ap"
30046718,"test"&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 06:21:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Consuming-REST-API-and-extracting-dynamic-nested-JSON-fields/m-p/2244449#M30601</guid>
      <dc:creator>lgati</dc:creator>
      <dc:date>2024-11-16T06:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Consuming REST API and extracting dynamic nested JSON fields</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Consuming-REST-API-and-extracting-dynamic-nested-JSON-fields/m-p/2244450#M30602</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;JSONPath do not support parent node, so if you need just id, value - you could use it&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JSONPath_1.PNG" style="width: 920px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M3Mm.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/148273i9C564BEC31829179/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M3Mm.png" alt="0683p000009M3Mm.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;result will be:&lt;/P&gt; 
&lt;PRE&gt;.--------+--------------.
|       tLogRow_2       |
|=-------+-------------=|
|id      |value         |
|=-------+-------------=|
|22827487|custom_extract|
|22798946|extracts      |
|21670316|3___medium    |
|30046718|null          |
'--------+--------------'&lt;/PRE&gt; 
&lt;P&gt;but if you need parent id as well (for join the tables), better to use XPath&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="XPath_001.PNG" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M3Mr.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/134785iBEAB16B8336FD1B0/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M3Mr.png" alt="0683p000009M3Mr.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;and result will be:&lt;/P&gt; 
&lt;PRE&gt;.---------+--------+--------------.
|            tLogRow_1            |
|=--------+--------+-------------=|
|ticket_id|id      |value         |
|=--------+--------+-------------=|
|99966685 |22827487|custom_extract|
|99966685 |22798946|extracts      |
|99966685 |21670316|3___medium    |
|99966685 |30046718|              |
'---------+--------+--------------'&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;P.S.&lt;/P&gt; 
&lt;P&gt;it is often not possible extract JSON/XML in flat structure with single component, so you need use more than 1 and join them back if need&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 22:07:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Consuming-REST-API-and-extracting-dynamic-nested-JSON-fields/m-p/2244450#M30602</guid>
      <dc:creator>vapukov</dc:creator>
      <dc:date>2019-03-11T22:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Consuming REST API and extracting dynamic nested JSON fields</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Consuming-REST-API-and-extracting-dynamic-nested-JSON-fields/m-p/2244451#M30603</link>
      <description>&lt;P&gt;&lt;A href="https://community.qlik.com/s/profile/005390000067LRbAAM"&gt;@vapukov&lt;/A&gt;how do I go about connecting many tExtractJson components to each other? or should I put a tMap in front of them to pass certain values to each of them?&lt;/P&gt;
&lt;P&gt;Also, should I use tUnite, to join all these tExtractJsons?&lt;/P&gt;
&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 23:25:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Consuming-REST-API-and-extracting-dynamic-nested-JSON-fields/m-p/2244451#M30603</guid>
      <dc:creator>lgati</dc:creator>
      <dc:date>2019-03-11T23:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Consuming REST API and extracting dynamic nested JSON fields</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Consuming-REST-API-and-extracting-dynamic-nested-JSON-fields/m-p/2244452#M30604</link>
      <description>&lt;P&gt;store extracted data - to memory hash or fils, and join them with tMap in next subjob&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it in case if you want to store all in the same flat table (where you will have a lot of duplicated information)&lt;/P&gt;
&lt;P&gt;or you could store all in normalized form, with foreign keys relations&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2019 00:09:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Consuming-REST-API-and-extracting-dynamic-nested-JSON-fields/m-p/2244452#M30604</guid>
      <dc:creator>vapukov</dc:creator>
      <dc:date>2019-03-12T00:09:25Z</dc:date>
    </item>
  </channel>
</rss>

