Is there a way to serialize a general object to Json and deserialize Json to the object?
If the object is an entity, I can use Jackson 2
lib to achieve the purpose.
But if the object is a general class, how can I do this?
For example, I'd like to serialize com.datastax.driver.core.querybuilder.Update
to Json and save it to DB, then search and deserialize it to Update
object, finally use it as the argument of com.datastax.driver.core.Session.execute(Statement)
to execuate.
Is it possible to reproduce Update
object?
COMPLEMENT:
My real purpose is to store Update
and then retrieve and execute it. So I thought I could save it as JSON String
and then retrieve and deserialize it into the original Update
instance and execute it. If It's not a good way, how can I store Update
and then retrieve and execute it?
Though I can store the text query
of Update
and the retrieve and execute the text query
, some other information in Update
maybe lose, like ConsistencyLevel
.