aspose file tools*
The moose likes Struts and the fly likes converting the json to bean exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "converting the json to bean exception" Watch "converting the json to bean exception" New topic
Author

converting the json to bean exception

swapnil kachave
Greenhorn

Joined: Feb 10, 2010
Posts: 27
Following exception is occur while using the json for converting the json to bean..


Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethodException: Property 'name' has no setter method
at net.sf.json.util.PropertySetStrategy$DefaultPropertySetStrategy._setProperty(PropertySetStrategy.java:69)
at net.sf.json.util.PropertySetStrategy$DefaultPropertySetStrategy.setProperty(PropertySetStrategy.java:60)
at net.sf.json.JSONObject.setProperty(JSONObject.java:1547)
at net.sf.json.JSONObject.toBean(JSONObject.java:364)
at net.sf.json.JSONObject.toBean(JSONObject.java:229)
at Json.json2bean(Json.java:53)
at Json.main(Json.java:13)
Caused by: java.lang.NoSuchMethodException: Property 'name' has no setter method
at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1782)
at net.sf.json.util.PropertySetStrategy$DefaultPropertySetStrategy._setProperty(PropertySetStrategy.java:67)
... 6 more
can any one know how to resolve this..
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Create a setter method for "name"?
avase kose
Greenhorn

Joined: May 04, 2011
Posts: 2
Hello,

Your class should be public

eg

public class xxx
{
}

not

class xxx
{
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: converting the json to bean exception