divergentor
8 years agoOccasional Contributor
How to parse JSON in javascript
Hello, community. I couldn't find a way to parse JSON in javascript. Could anybody help me? I casual JS I can use JSON.parse. But it is invalid case for SOAPUI. I know that for grove it's a...
- 8 years ago
SoapUI 5.3 uses an older version of the Rhino engine (1.7R2) that does not support JSON.parse(), but there are a couple of workarounds.
Option 1: use eval()
var str = '{"foo": "bar"}'; var obj = eval('(' + str + ')'); log.info(obj.foo);
Option 2: Update Rhino engine and use JSON.parse()
- Download the latest version of Rhino from here:
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Download_Rhino - In the <SoapUI>\lib folder, replace js-1.7R2.jar with js-<ver>.jar from the downloaded archive.
- Restart SoapUI.
Now you can use JSON.parse():
var str = '{"foo": "bar"}'; var obj = JSON.parse(str); log.info(obj.foo);
- Download the latest version of Rhino from here: