Reputation: 167
I'm trying to use org.json on groovy SoapUI to convert a JSON string into XML.
But When I'm trying to perform my groovy script (this one)
import org.json.JSONObject
import org.json.XML
def str = "{'name':'JSON','integer':1,'double':2.0,'boolean':true,'nested':{'id':42},'array':[1,2,3]}";
JSONObject json = new JSONObject(str);
String xml = XML.toString(json);
log.info(xml)
I'm getting an error "unable to resolve class org.json.JSONObject , line 1, column 1.
I downloaded the jar on http://mvnrepository.com/artifact/org.json/json/20141113 , I put it on SoapUI/bin/ext but It's not working.
Can someone please help me with this?
Upvotes: 0
Views: 1724
Reputation: 18507
Coping the json-20141113.jar
in SOAPUI_HOME\bin\ext
works for me, and your code executes correctly, logging this:
Thu Feb 12 21:58:53 CET 2015:INFO:<boolean>true</boolean><array>1</array><array>2</array><array>3</array><double>2.0</double><name>JSON</name><integer>1</integer><nested><id>42</id></nested>
Note that in order to load the libraries you must restart SOAPUI
, maybe this is causing your error.
Note also that the jar
you linked is compiled with java 1.8
so check if you run SOAPUI
using this version of java if not then you will receive Unsupported major.minor version 52.0
error. I say this because SOAPUI
is available to download with or without java; if you download it with java the version is java 1.7
. If this is the case you must download java 1.8
and modify SOAPUI_HOME\bin\soapui.bat
to use the correct version.
Hope this helps,
Upvotes: 1