映射序列化为json中的数组,如何编写相应的解串器! [英] Map serialized to array in json, how to write the corresponding deserializer !

查看:90
本文介绍了映射序列化为json中的数组,如何编写相应的解串器!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用ObjectMapper来序列化包含地图的对象,以便相应的序列化json文本有一个数组而不是地图。 />


- 首先,我遇到了JsonTypeInfo的问题。它没有在json文本中序列化,但是当我不使用我的自定义序列化器时(map - >数组)



- 另一个问题,是我不知道如何编写自定义反序列化器来反序列化要映射的数组。



我在这里写了一个示例项目:GitHub - mike03081972 / sortedmaptest [ ^ ]



普通串行器/解串器可以测试:Tests.serializeDeserializeTest



自定义序列化器可以测试:Tests.customSerializeTest



我尝试过:



谷歌搜索:

java - 反序列化使用Jackson进行映射的JSON数组 - Stack Overflow [ ^ ]

.. 。

Hi,

I'm using ObjectMapper to serialize an object containing a map so that the corresponding serialized json text have an array instead of the map.

- First, I have a problem with JsonTypeInfo. It is not serialized in the json text but it is when I don't use my custom serializer (map -> array)

- An other problem, is that I don't know how to write the custom deserializer to deserialize the array to map.

I have write an example project available here : GitHub - mike03081972/sortedmaptest[^]

Normal serializer/deserializer can be tested with : Tests.serializeDeserializeTest

Custom serializer can be tested with : Tests.customSerializeTest

What I have tried:

google search :
java - Deserialize JSON array to Map using Jackson - Stack Overflow[^]
...

推荐答案

找到第二点的解决方案:编写自定义反序列化器



但是找不到第一个关于JsonTypeInfo
Solution found for the second point : write custom deserializer

But nothing found for the first problem regarding the JsonTypeInfo


这篇关于映射序列化为json中的数组,如何编写相应的解串器!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆