Hi,
I am trying to write the workflow to parse the JSON files and retrieve the all keys and their values from JSON file but I could not find the appropriate APIs for the same. How we can write the workflow to parsing JSON file and retrieve values from file?
-AVR
Take a look at FileReader class in vCO API Explorer.
First you can use FileReader#readAll() to read the content of the file as string, and then use JSON.parse() to parse this content string and convert it to Javascript object.
var javascriptObject = JSON.parse(jsonString);
var value = javascriptObject.key;
Thanks buddy for your response, I already wrote the code using JSON.parse(). I got confused how to handle different data types like “Array” that JSON contain and what should be the return from this utility workflow, property object that contains key value or something else that is useful for other calling workflow. Basically I need some idea for this JSON parser utility workflow.
Try with return type Any to see if it suits your use cases.
Also, consider implementing this utility not as a workflow but as a scripting action.
I have successfully written utility Action to parse the JSON file and return Properties object. Now I would like to create another utility action / workflow in vCO tp validate the input JSON file against JSON schema file, how we can write this any idea.