How to convert databank text string to JSONObject?
I am extracting a json response to dataBank variable and assigning to extension tool.
On top of the extension tool adding json databank.
Getting error as invalid json.
is there any option like Transformer for json, like we have XMLTransformer for XML?
Comments
-
Have you validated that what you are passing to the JSON Data Bank is formatted as valid JSON?
0 -
Hello..
In JSON Data Bank "myDataBank" I have created a Data Source column named "persons" that has value in the format
{
"person" : [
{
"firstName" : "ABC",
"lastName" : "XYZ"
}
]
}When I extract the Datasource column "persons" using
var personList = context.getValue("myDataBank", "persons");
personList is a string not an object or an array. How to convert string to JSON or is there any way to access the string data in personList.
Something like personList[0].firstName
0 -
One option is to change your data bank to extract the string directly (like "firstName") instead of "person". Or, if you are using scripting, you could use JavaScript (Oracle Nashorn) as your scripting language and use JSON.parse() to turn the string into a JSON object that you can use.
0 -
I changed to JavaScript (Oracle Nashorn). It worked. Thank you.
0