Upgrade path of Java – JSON file format

We use Jackson to store user preferences for Java applications in JSON files As we continue to develop applications, we will add preferences, rename preferences, and delete outdated preferences The file format may have changed when the user upgrades the application to the next version This will cause Jackson to throw an exception. Even if the format is the same, the file cannot be parsed How do I handle upgrading file formats?

I am considering using jsont to upgrade files and writing my own Jackson stream parser, which is more relaxed than the fully bound parser in case of problems in jsont upgrade How do others handle upgrading file formats?

Solution

Jackson currently does not have any built-in JSON version support, such as gson doors Jackson issue 108 was recorded two years ago to address this possible enhancement problem Please do not hesitate to vote for its implementation I've done it

The approach I will take is to implement a custom JSON version control solution, similar to the way gson works (using this function alone may not be enough for me to switch to gson.) Then, the logic in java bean processing may be relatively simple for handling different versions after deserialization or during custom deserialization

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>