简体   繁体   中英

Save the Configuration of a Jackson ObjectMapper

Does Jackson provide a means of saving the configuration of an ObjectMapper and then recreating it from this saved information?

In my particular case, I need to be able to record along with some data what modules were in use by the mapper when the data was written so that the same modules can be loaded for deserialization.

Update: The reason for this is the need to store some data with the sequence of transformations that was applied to create that data. All of these transformations implement a known interface, but otherwise nothing is known about them and many different ones will be implemented by users. When serializing, it may be necessary to load modules in order to serialize some of the transformations. We'd like to be able to deserialize these transformations later in order to transform new data in the same way as the existing data, but without knowing what modules were loaded into the ObjectMapper, deserialization may fail.

ObjectMapper is actually java.io.Serializable , if you REALLY want to do this. I wouldn't necessarily recommend it, but it is possible. It is used by some on Android, to reduce cost of re-creating mapper instances (due to the way Dalvik swaps out apps).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM