0

我在使用 JSONArray.fromObject(jsonObj) 时遇到 JSONException。我无法弄清楚这个异常背后的原因。有人可以提供某种关于为什么会发生此错误的输入吗?

 net.sf.json.JSONException: java.lang.reflect.InvocationTargetException
at net.sf.json.JSONObject._fromBean(JSONObject.java:987)
at net.sf.json.JSONObject.fromObject(JSONObject.java:168)
at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:265)
at net.sf.json.JSONObject._processValue(JSONObject.java:2808)
at net.sf.json.JSONObject.processValue(JSONObject.java:2874)
at net.sf.json.JSONObject.setInternal(JSONObject.java:2889)
at net.sf.json.JSONObject.setValue(JSONObject.java:1577)
at net.sf.json.JSONObject._fromMap(JSONObject.java:1340)
at net.sf.json.JSONObject.fromObject(JSONObject.java:159)
at net.sf.json.AbstractJSON._processValue(AbstractJSON.java:265)
at net.sf.json.JSONArray._processValue(JSONArray.java:2514)
at net.sf.json.JSONArray.processValue(JSONArray.java:2539)
at net.sf.json.JSONArray.addValue(JSONArray.java:2526)
at net.sf.json.JSONArray._fromCollection(JSONArray.java:1057)
at net.sf.json.JSONArray.fromObject(JSONArray.java:123)
at net.sf.json.JSONArray.fromObject(JSONArray.java:105)
at net.sf.json.JSONArray$fromObject.call(Unknown Source)

代码如下:

RESTClient restClient = new RESTClient(uri)
        Map<String, String> args = new HashMap<String,String>();
        args.put("responseContentType","ContentType.JSON");
        response = restClient.get(args)
        Object jsonObj = response?.getData()
        JSONArray jsonResp = JSONArray.fromObject(jsonObj)

我从 REST 服务得到的响应如下:

[{"contract":"/api/v1/contracts/3","draw":"/api/v1/draws/5","drawName":null,"drawNumber":1,"id":5,"periodFrom":"2007-01-10","periodTo":"2007-02-10"}]
4

0 回答 0