Make JSONObject Serializable
deserialization, grails, java, serialization, session
Solution
I think the `toString` method is what's intended to be used here. That method already returns the JSON text of the object, which is suitable for transmitting or storing.
Problem
`JSONObject` class of package `org.codehaus.groovy.grails.web.json` does not implement `Serializable`. I want to make this object serializable as I am using session replication among application servers and `JSONObject` gets saved in session. I have two options to achieve this: - Subclass `JSONObject`s that implements `Serializable`. - use `toString()` method on `JSONObject` object while saving this object in session. Can anyone please suggest which one of two options should I use and what is the reason?