Alteryx Designer Desktop Discussions

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

JSON Parse tool is not working

nazrin_guliyeva
7 - Meteor

I am fetching data using Python Tool and writing it to the dataframe. Some of the fields are in JSON format

nazring_2-1596530341156.png

 

which I need to normalize. For this, I am using Formula Tool to remove first and last square brackets ([]). However, when I am using Parse Tool, I am not getting anything as in the screenshot. 

nazring_0-1596530170188.png

My workflow is as following:

nazring_1-1596530201070.png

I have uploaded the results before formula tool as well. 

 

Any helps would be really appreciated!

 

Thanks in advance

 

 

 

3 REPLIES 3
kumaranvr1984
8 - Asteroid

Hi @nazrin_guliyeva ,

 

Try the attached workflow, the json parse takes double quote.

 

 

Regards,

Kumaran 

grazitti_sapna
17 - Castor

Hi @nazrin_guliyeva ,

 

If you are exporting a python Dictionary (Which does look a lot like a JSON), that would explain why Alteryx isn't seeing it as a valid JSON string.

 

What you could do in your python output is to convert the dictionary to a JSON string using the dumps() function from the JSON module within python. The JSON conversion in python will be much more performant than the string operation to replace the ' with " and you wont have to consider handling issues where ' is in the contents of the JSON values.

 

See below code snippet from https://stackoverflow.com/questions/26745519/converting-dictionary-to-json

import json

r = {'is_claimed': 'True', 'rating': 3.5} #Sample python dictionary
type(r) #Output dict
r = json.dumps(r)
type(r) #Output str

By using json.dumps() function in your python code itself will fix the issue of single quote and will parse your json output.

 

I hope it helps.

Thanks.

Sapna Gupta
grazitti_sapna
17 - Castor

Hi @nazrin_guliyeva , if the issue is resolved kindly mark the post as solved so that it can help other users as well.

Thanks.

Sapna Gupta
Labels