Hi +1 on this queistion. Some time ago personally i asked the same question. But we still don't have impelmentaiton :) Maybe you can produce it ?
In my projects i've been usign StringRepresentaion and other 'hacks' to produce output using Json-lib and not internal Restlet JSON support. > I am a new user of Restlet (and quite hapy with it, too), but I found > that using the JSON classes that come with it do not work well enough > for me. They do serialize basic classes, but do not work on things like > HashMap, or really anything nested. I checked the main JSON website to > see if there were newer versions of those classes (there are), but they > still do not on nested objects. > > JSON-Lib does work well for this, so I switched to using that. However, > when I want to create a representation out of the new (JSON-Lib) > JSONObject, it does not accept the type. > > Representation representation = new JsonRepresentation(json); > > The warning is: "Type safety: The expression of type JSONObject needs > unchecked conversion to conform to Map<Object,Object>" > > The reason is because "json" is of type "net.sf.json.JSONObject" instead > of "org.json.JSONObject". Ultimately, the best solution is for > "net.sf.json.JSONObject" to extend "org.json.JSONObject", as is done > with other JSON libraries I have tested, but I seriously doubt this is > going to happen. I can "fix" the issue by doing this instead: > > Representation representation = new > JsonRepresentation(json.toString()); > > It just seems wasteful to have a usable JSONObject, convert it to a > string and then pass it to a constructor. > > Has anyone successfully used JSON-Lib with Restlet without resorting to > a hack like this? Also, is there a reason that Restlet only works with > the basic "org.json.*" library? I would think that JSONObject should be > handled in the way logging is handled: you can use the basic built-in > logging in the JDK, or use something else, like Log4J. Can this also be > done with "org.json.*" and other JSON implementations, too? > > I very much would appreciate any replies / suggestions. > > Mike V. > > ------------------------------------------------------ > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1014233 > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1018641

