Home  >  Forum  >  Struts
Post New Query

JSONException: java.lang.ClassCastException: JSON keys must be strings


joined on
August 11,2014
Asked on January 17,2015
Hi,

I am creating struts 2+ Web service with JSON. I getting error as below.

net.sf.json.JSONException: java.lang.ClassCastException: JSON keys must be strings.
at net.sf.json.JSONObject._fromMap(JSONObject.java:1357)
at net.sf.json.JSONObject.fromObject(JSONObject.java:159)
at net.sf.json.JSONObject.fromObject(JSONObject.java:130)
at org.apache.struts2.rest.handler.JsonLibHandler.fromObject(JsonLibHandler.java:72)
at org.apache.struts2.rest.DefaultContentTypeHandlerManager.handleResult

(DefaultContentTypeHandlerManager.java:139)
at org.apache.struts2.rest.RestActionInvocation.executeResult(RestActionInvocation.java:232)
at org.apache.struts2.rest.RestActionInvocation.processResult(RestActionInvocation.java:197)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:145)
at com.opensymphony.xwork2.DefaultActionProxy.execute(DefaultActionProxy.java:147)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter
joined on
October 10,2013
Replied on January 17,2015

Stack trace is clearly saying that in your Endpoint of web service has Non string parameter to accept JSON data. While accepting JSON data, we must keep property as String.
If we keep it Integer, then there will be ClassCastException.

Write Answer








Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us