How to convert a string to a JSON array

When we use JSON data generated by a Python script, we must keep in mind that they may contain additional backslashes in them. Hence, these data cannot be directly used in Studio Pro for processing.

mceclip0.png

In this article, you find an easy solution to solve this situation, so you can work with the JSON file successfully.

Instructions

To remove the backslashes from the JSON data returned by the Python script, do as follows:

  1. Using the Create file activity, create a JSON file and write the JSON data to it.
  2. Next, use the Read text file activity with the “File type” selected as JSON.
  3. Run the workflow.

Check the newly created JSON file. Notice that the data is read properly without any backslashes.

mceclip1.png

3 Likes

Hi @Kevin.ameda

I hope you are doing well!

Firstly I think we can use it that form of data. For example if you pass that variables data, generated by python script, into input activity and enters the data somewhere. The Studio Pro automatically removes the backslashes and enters the data perfectly.

Secondly the method you have used is interesting. Can you please share the workflow for this?

Thanks in advance!

Kind Regards,
Muhammad Hayyan Khan

1 Like