Issue
I am replacing an in-house caching system with memcached but memcached client cannot cache the JsonNode
objects since they don't implement Serializable
.
Is there any way you can achieve serializing a JsonNode
object? Does Jackson provide Serializable
equivalent of this class?
Solution
JSON is best serialized by writing it out as bytes. In Jackson, it is done using ObjectMapper
, for example by:
byte[] raw = objectMapper.writeValueAsBytes(root);
MemCache does not really need Serializable since it's all raw bytes; although Java clients may try to be helpful and handle serialization.
Answered By - StaxMan Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.