JSON Parse tool is not working
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I am fetching data using Python Tool and writing it to the dataframe. Some of the fields are in JSON format
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.
My workflow is as following:
I have uploaded the results before formula tool as well.
Any helps would be really appreciated!
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @nazrin_guliyeva , if the issue is resolved kindly mark the post as solved so that it can help other users as well.
Thanks.
