FasterXML / FasterXML/jackson-databind

Support optional serialization/deserialization of map with non-string key type

オープン
#3,283 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
3.7k
フォーク
1.5k
平均マージ
3日 6時間
マージ済み PR(30日)
28

説明

**Is your feature request related to a problem? Please describe.**

Based on https://github.com/FasterXML/jackson-module-scala/issues/316 and some other issues that have popped up where users want to work with Map where the KeyClass can't be readily represented as a String.

**Describe the solution you'd like**

Typically, Maps (eg `Map(1 -> "a", 2-> "b")`) are serialized as something like:

```
{
"1": "a",
"2": "b"
}
```

But we could have a way to annotate this Map so that it gets serialized as:

```
[
{
"key": 1,
"value": "a"
},
{
"key": 2,
"value": "b"
}
]
```

The names of the JSON elements `key` and `value` could be made configurable.

This latter serialization could allow the key value to be represented as a JSON object or array.

This serialization might be useful for someone who wanted to JSON serialize a Map as opposed to using Java serialization.

**Additional context**
Not urgent. Just opened as a discussion topic. Users can currently write their own custom serializers and deserializers to achieve this.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。