我有一个库org.json.JSONArray
,需要将其转换为org.json.simple.JSONArray
。
我使用的网络服务器有一个返回org.json.simple.JSONArray
的界面,因此我需要将org.json.JSON array
转换为它。
我也尝试将响应转换为org.json.JSONArray
,但基于Jersey的Web服务器无法将其转换为HTTP响应。
答案 0 :(得分:0)
能够使以org.json.JSONArray
形式返回org.json.simple.JSONArray
的库(A Unirest包装器)返回。这解决了这个问题。
Unirest.setTimeouts(1000000,1000000);
HttpResponse<String> jsonResponse = Unirest.post(host)
.header("Content-Type", "application/json")
.body(String.format("{\"queryType\":\"%s\", \"query\":\"%s\"}", "SQL",
query))
.asString();
JSONParser parser = new JSONParser();
String json = jsonResponse.getBody();
return (JSONObject) parser.parse(json);