Articles → AUTOMATION ANYWHERE → Read Json Data In Automation Anywhere

Read Json Data In Automation Anywhere






Steps




  1. Create a python program to read json data.
  2. Open command prompt in automation anywhere.
  3. Execute the python program and put output in text file
  4. Read text file.



Create A Python Program To Read Json Data




import json


# some JSON:
x = '{ "name":"Karan", "age":37, "city":"Gurgaon"}'

# parse x:
y = json.loads(x)

print(y["name"])
print(y["age"])
print(y["city"])





Open Command Prompt In Automation Anywhere




Picture showing the popup window of Open Program/File command in automation anywhere to open command prompt
Click to Enlarge


Execute The Python Program And Put Output In Text File




c:\python\python c:\temp\test.py > c:\temp\output.txt




  1. First parameter is the path of python.exe.
  2. Second parameter is the path of python file.
  3. Third parameter is the path of output file.


Picture showing the popup window of Insert Keystrokes command to execute the python program
Click to Enlarge


Read Text File




Picture showing the popup window of Read From CSV/Text command for reading the text file
Click to Enlarge



Picture showing the code for displaying text file content using the message box command
Click to Enlarge


Output


Picture showing displaying the text file content using the message box
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, June 13, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250