Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

JSON Parse Tool

Lazzanova
7 - Meteor

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 

6 REPLIES 6
grazitti_sapna
17 - Castor

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

Thanks.

Sapna Gupta
Lazzanova
7 - Meteor

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?

grazitti_sapna
17 - Castor

@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

 

Sapna Gupta
JonMcMillin
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

 

Lazzanova
7 - Meteor

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

Problem is solved.

grazitti_sapna
17 - Castor

@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.

Sapna Gupta
Labels