Alteryx Designer

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

JSON Parse Tool

Highlighted
5 - Atom

Hello guys,

I hope you can help me out here.

Lazzanova_0-1593507922590.png


I'm trying to get the content of a JSON file here, using the JSON Parse Tool. The Column Content is in JSON Format, however, when I use the JSON Parse tool, I get the following error:

Lazzanova_1-1593508066348.png


Missing a name for object member, at character position 1.

Can any of you help me out?

With kind regards,

 

Önder 

Highlighted
Alteryx Partner

HI @Lazzanova , will it be possible for you to share the workflow? Also it looks like a conversion error to me.

Thanks.

Highlighted
5 - Atom

Unfortunately I couldn't share the Python code, because it contains login credentials. However I did share the results of it in an Excel file.
Will this help?

Highlighted
Alteryx Partner

@Lazzanova , yes thank you that worked, the problem is in the json data you fetched as that's not valid json. json uses ", not '.

 You need to use formula tool after fetching the data from your python code and replace all the single qoutes with double quotes and it will work.

I hope it helps.

Thanks.

grazitti_sapna_1-1593515456415.png

 

 

grazitti_sapna_0-1593515436961.png

 

Highlighted
8 - Asteroid

Hi @Lazzanova ,

 

In addition to conversion that @grazitti_sapna suggested, something you should investigate is the type of field you are exporting from the python script.

 

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

 

Highlighted
5 - Atom

Thanks guys, I've altered the Python code and made sure the output became with double quotes instead of single quotes.

Problem is solved.

Highlighted
Alteryx Partner

@Lazzanova Glad to know it is fixed, it did not come into my mind that you might not be using json.dump() in the code.

Labels