Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
VB2020
Contributor II
Contributor II

Parse JSON embedded array to single rows

Hello,

I have some JSON code (below) which I need to parse and transform into a single row in an output CSV or XLSX file. Should this be done as separate fields for 'questionId', 'answer' and 'comment' in tExtractJSONFields components or could this be done in the tMap component? The number of nodes within each 'responses' embedded array would remain consistent - 3 nodes within each instance of 'responses' (i.e., questionId1, questionId2, questionId3, and so on for the other fields). The below JSON is a small example - the actual JSON is much larger but the structure and content is exactly the same as below.

I need to change this:

{

  "data": [

    {

      "id": "101",

      "type": "doc",

      "attributes": {

        "documents": {

          "responses": [

            {

              "questionId": "1",

              "answer": "N",

              "comment": null

            },

            {

              "questionId": "2",

              "answer": "N",

              "comment": null

            },

            {

              "questionId": "3",

              "answer": "Y",

              "comment": null

            }

          ]

        }

      },

  ],

  "meta": {

    "totalCount": null

  }

}

into the output image attached (I was unable to paste it in place here)

Please advise as to how this can be done. Thank you.

Labels (4)
1 Solution

Accepted Solutions
evansdar
Contributor II
Contributor II

This configuration worked for me, although you may need to change it a bit once you use the full JSON

0693p000009I39yAAC.png

 0693p000009I37jAAC.png

View solution in original post

4 Replies
evansdar
Contributor II
Contributor II

This configuration worked for me, although you may need to change it a bit once you use the full JSON

0693p000009I39yAAC.png

 0693p000009I37jAAC.png

VB2020
Contributor II
Contributor II
Author

@Daniel Evans​  That's exactly what I need. I'm trying to work from your example, but please clarify - how did you manage to choose "content" from the 'JSON field' dropdown in your tExtractJSONFields_1 subjob when "content" isn't in my sample JSON? Is "content" something you added to your schema? If so, could you please show me where you added it?

evansdar
Contributor II
Contributor II

It really depends on how your JSON is being retrieved. Are you using a webservice, or pulling directly from a file? I named the column myself, and used a tFileInputRaw with 'Read as String' selected for your example.

 

The JSON Field here is not anything within the JSON itself, rather how Talend/Java identifies the JSON you are passing

 

 

VB2020
Contributor II
Contributor II
Author

@Daniel Evans​  Your solution has worked for me also. Many thanks for your help and guidance.