java - json data storage with versioning -
problem definition:
there java server stores json
data can mapped java class. java class subject changes. goal able update java class , still able decode json
data of older version java object of newer version. there should versioning system in place. example ability add new field java class default value. in case old json
data doesn't have field, java object can use default value of field.
questions:
- i've seen
gson
, the versioning support limited.
did miss something? there other libraries have better versioning support?
- how should 1 store
json
data?
i see 2 options. option 1: can store json
files (which have common structure if have same version) separately in folder. example have 2 files: json/j1.json , json/j2.json. option 2: can use nosql
database such mongodb
. have advantage on previous option? pointless ask basicdbobject
in dbcollection
since need able cast java class. option recommended case? maybe option better suited?
there no built-in jackson support @ time of writing (2.9.x), however, jackson model versioning module adds versioning support can used convert old versions of json models current version (and vice-versa) before being mapped pojo.
see answer on jackson 2 support versioning example of how gson's basic versioning functionality can mapped module. see module's github page examples of full functionality.
disclaimer: author of module. have written spring mvc responsebodyadvise using module.
Comments
Post a Comment