Alteryx Designer Desktop Discussions

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

JSON Parse - to cross tab format

Masond3
8 - Asteroid

Hi Team, 

Hope all is well. 

I have some Json data, that i would like to parse and and get into a readable format ( as shown in the desired outcome) 

Unfortunately i don't know all the header names, but hoping it can be dynamic enough to pick up and align the data accordingly. 

 

Input 

JSon_DataRecordID
{"ADDRESS_LIST":[{"PRIMARY_ADDR_CITY":"Test  SAONE","PRIMARY_ADDR_COUNTRY":"FR","PRIMARY_ADDR_LINE1":"123 Test Street  Desmoulins","PRIMARY_ADDR_LINE2":"EMEA","PRIMARY_ADDR_POSTAL_CODE":"69400","PRIMARY_ADDR_TYPE":"HOME"}],"EMAIL_LIST":[{"EMAIL1
{"ADDRESS_LIST":[{"PRIMARY_ADDR_CITY":"Test SAONE","PRIMARY_ADDR_COUNTRY":"FR","PRIMARY_ADDR_LINE1":"123 Test Avenue Desmoulins","PRIMARY_ADDR_LINE2":"EMEA","PRIMARY_ADDR_POSTAL_CODE":"69400","PRIMARY_ADDR_TYPE":"HOME"}],"EMAIL_LIST":[{"EMAIL2

 

Desired outcome 

RecordidPRIMARY_ADDR_CITYPRIMARY_ADDR_COUNTRYPRIMARY_ADDR_LINE1PRIMARY_ADDR_LINE2PRIMARY_ADDR_POSTAL_CODE
1Test SAONEFR123 Test Street EMEA69400
2Test SAONEFR123 Test AvenueEMEA

69400

 

Looking forward to your assistance 

 

Many thanks 

Masond3

14 REPLIES 14
binuacs
21 - Polaris

@Masond3 one way of doing this with the json parse tool

image.png

OllieClarke
15 - Aurora
15 - Aurora

Hey @Masond3 
This is my approach to parsing Json

image.png

After the json parse tool, you break JSON_Name into its constituent values based on '.' (this will vary depending on your json, and may even vary within your json if it's nested).

Then I rename, drop and retype fields (you sometimes need to split your data before this step, as JSON_Name2 could be a row indicator for some of your data, but a header for others)

Then cross tab, grouping by all numeric fields

Hope that helps,

 

Ollie

Masond3
8 - Asteroid

@OllieClarke  hank you for your prompt response and the detailed comments embedded in the workflow. After running your query on my dataset, I noticed that some entries in the json_name field do not contain a period (".").

Example 

 

ADDRESS_LIST.0.PRIMARY_ADDR_CITY
ADDRESS_LIST.0.PRIMARY_ADDR_COUNTRY
GROUP_ASSOCIATION_ORG_NAME
RECORD_TYPE

 

if i want, GROUP_ASSOCIATION_ORG_NAME & RECORD_TYPEto be grouped together, whats the best way to achieve this ? 

Many thanks 

OllieClarke
15 - Aurora
15 - Aurora

Hi @Masond3 

I was working off the json you shared (which wasn't complete). This is one of those examples where we need to separate our json.

 

Based just on the original input and what you added above, here's how I would deal with that. This approach scales though, so once you've worked out many layers of json you have, you'd filter to each layer, cross tab it out, then join them all together at the end

image.png

 

Hope that helps,

 

Ollie

Bhavyapaliwal20
6 - Meteoroid

Please check this workflow .

 

Screenshot 2024-09-17 193624.png

 

Masond3
8 - Asteroid

@Bhavyapaliwal20  @OllieClarke 

Thank you for providing your solutions.

While analyzing more data, I believe I have identified the problem.

Initially, I observed that the json_name field does not contain a period ("."). This observation still holds true.

However, upon further investigation, I also noticed that there can be multiple attributes for the same record ID, which often have the value "ALT" in the json_valuestring. This is indicated in json_name as ".1".

This seems to only appear for the following two types: Email_Address and Phone_Number.

 

For example,

Record id JSON_NameJson_valueString
1PHONE_LIST.0.PHONE_NUMBER222.222.2222
1PHONE_LIST.0.PHONE_TYPEPhone
1PHONE_LIST.1.PHONE_NUMBER111.111.1111
1PHONE_LIST.1.PHONE_TYPEALT


The desired output is the same 

Record id PHONE_NUMBERPHONE_NUMBER_ALT
1 222.222.2222 111.111.1111
Bhavyapaliwal20
6 - Meteoroid

 I Am not getting . You want this output aur want to want exactly.

Masond3
8 - Asteroid

@Bhavyapaliwal20  

I would like to cross-tabulate all the JSON names and values to create a single row. The JSON names should be placed across the top as column headers, and the corresponding values should be populated under the appropriate JSON names.

For example, I have two entries for phone numbers: one is the primary phone number, and the other is an alternative phone number. This distinction is indicated by the node tree structure, where PHONE_LIST.0.PHONE_NUMBER represents the primary phone number and PHONE_LIST.1.PHONE_NUMBER represents the alternative phone number.

To differentiate between the two values:

  • PHONE_LIST.0.PHONE_NUMBER Type = Phone
  • PHONE_LIST.1.PHONE_NUMBER Type = Alt
Bhavyapaliwal20
6 - Meteoroid

do you want change column names??

 

Labels
Top Solution Authors