Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How to handle Json Nested Structures

Masond3
8 - Asteroid

Hello Team,

I hope this message finds you well.

I have an input file that includes an two columns, ID and  "DownloadData," (which contains JSON response).

I've attempted to parse the data in the "DownloadData" column, but I'm only able to retrieve a portion of the data. Whilst inspecting the Json it appears, the JSON includes nested arrays and objects, such as ind_other_names and ind_ia_current_employments. and i am a little stuck on how to break these out. 


The Desired out put is to generate 2 Columns 
ID
Json_Name 
Json_String 

Once i have broken it all out into , i would cross tab to get it back to a  single row 

Excepted outcome 

 

IDind_source_idind_firstnameind_middlenameind_lastnameind_other_namesind_bc_scopeind_ia_scopeind_ia_disclosure_flind_approved_finra_registration_countind_employments_countind_industry_cal_date_iapdfirm_idfirm_namebranch_citybranch_statebranch_zipia_onlyfirm_bd_sec_numberfirm_bd_full_sec_numberfirm_ia_sec_numberfirm_ia_full_sec_numberfirm_idfirm_namebranch_citybranch_statebranch_zipia_onlyfirm_bd_sec_numberfirm_bd_full_sec_numberfirm_ia_sec_numberfirm_ia_full_sec_number
ABC11111 Test ROBERT TestTest Test Active Active N12 2024-12-111252 Test L.L.C. New York NY94104 Y9999 8-2698688 801-6881252 Google SAN FRANCISCO CA94189 N2698 8-2698688 801-688



Looking forward to your help

JSon Response in DownloadData 

 

{"hits": {"total": 1, "hits": [{"_type": "_doc", "_source": {"ind_source_id": "11111", "ind_firstname": "Test", "ind_middlename": "ROBERT", "ind_lastname": "Test", "ind_other_names": ["Test Test"], "ind_bc_scope": "Active", "ind_ia_scope": "Active", "ind_ia_disclosure_fl": "N", "ind_approved_finra_registration_count": 1, "ind_employments_count": 2, "ind_industry_cal_date_iapd": "2024-12-11", "ind_ia_current_employments": [{"firm_id": "1252", "firm_name": "Test L.L.C.", "branch_city": "New York", "branch_state": "NY", "branch_zip": "94104", "ia_only": "Y", "firm_bd_sec_number": "9999", "firm_bd_full_sec_number": "8-2698", "firm_ia_sec_number": "688", "firm_ia_full_sec_number": "801-688"}, {"firm_id": "1252", "firm_name": "Google", "branch_city": "SAN FRANCISCO", "branch_state": "CA", "branch_zip": "94189", "ia_only": "N", "firm_bd_sec_number": "2698", "firm_bd_full_sec_number": "8-2698", "firm_ia_sec_number": "688", "firm_ia_full_sec_number": "801-688"}]}, "highlight": {"ind_source_id": ["<em>245855</em>"]}}]}}



Json Response Print Pretty

 

 

{
  "hits": {
    "total": 1,
    "hits": [
      {
        "_type": "_doc",
        "_source": {
          "ind_source_id": "11111",
          "ind_firstname": "Test",
          "ind_middlename": "ROBERT",
          "ind_lastname": "Test",
          "ind_other_names": [
            "Test Test"
          ],
          "ind_bc_scope": "Active",
          "ind_ia_scope": "Active",
          "ind_ia_disclosure_fl": "N",
          "ind_approved_finra_registration_count": 1,
          "ind_employments_count": 2,
          "ind_industry_cal_date_iapd": "2024-12-11",
          "ind_ia_current_employments": [
            {
              "firm_id": "1252",
              "firm_name": "Test L.L.C.",
              "branch_city": "New York",
              "branch_state": "NY",
              "branch_zip": "94104",
              "ia_only": "Y",
              "firm_bd_sec_number": "9999",
              "firm_bd_full_sec_number": "8-2698",
              "firm_ia_sec_number": "688",
              "firm_ia_full_sec_number": "801-688"
            },
            {
              "firm_id": "1252",
              "firm_name": "Google",
              "branch_city": "SAN FRANCISCO",
              "branch_state": "CA",
              "branch_zip": "94189",
              "ia_only": "N",
              "firm_bd_sec_number": "2698",
              "firm_bd_full_sec_number": "8-2698",
              "firm_ia_sec_number": "688",
              "firm_ia_full_sec_number": "801-688"
            }
          ]
        },
        "highlight": {
          "ind_source_id": [
            "\u003Cem\u003E245855\u003C/em\u003E"
          ]
        }
      }
    ]
  }
}

 

 

 

 

 

9 REPLIES 9
Raj
16 - Nebula

@Masond3 
add the expected output.
will be in better position to help.

Raj
16 - Nebula

@Masond3 
find attached a starter for solution this will help.
Mark done if solved.

Masond3
8 - Asteroid

@Raj Just uploaded expected outcome. (Hope that helps) 

Raj
16 - Nebula

@Masond3 
you can not have 2 columns with same name
also please take a look at the attached solution above.
that will definitely help.

Raj
16 - Nebula

@Masond3 
find the updated
you can easily join this and get the result.

mark done if solved.

Masond3
8 - Asteroid

Hi @Raj  Thank you for providing your insights. So i have just rechecked my flow 

I am saving my input as a CSV. 
DownoadData type = V_String &  Size 254 

When i am viewing this field within alteryx, all i can see is this : 

{"hits": {"total": 1, "hits": [{"_type": "_doc", "_source": {"ind_source_id": "11111", "ind_firstname": "Test", "ind_middlename": "ROBERT", "ind_lastname": "Test", "ind_other_names": ["Test Test"], "ind_bc_scope": "Active", "ind_ia_scope": "Active", "in

When i add my input on to your flow, all i get is following  fields exposed. Where your filter is  hits.hits.0._source.ind_ia_current_employments. nothing is comming out of the true leg, the below comes out of the false leg.


 

hits.total1
hits.hits.0._type_doc
hits.hits.0._source.ind_source_id11111
hits.hits.0._source.ind_firstnameTest
hits.hits.0._source.ind_middlenameROBERT
hits.hits.0._source.ind_lastnameTest
hits.hits.0._source.ind_other_names.0Test Test
hits.hits.0._source.ind_bc_scopeActive
hits.hits.0._source.ind_ia_scopeActive
Raj
16 - Nebula

@Masond3 change the size of data to 9999999999.

Masond3
8 - Asteroid

@Raj  - As soon as you said that i did it and it worked. Thanks for the nudge, sometimes i need people like you to bounce the ideas off of 

Raj
16 - Nebula

@Masond3 
if this is solved
mark the solutions as done.

happy to help.

Labels