PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, November 13, 2022

[FIXED] How can I serialize Jackson's JsonNode object?

 November 13, 2022     jackson, memcached     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing