FasterXML / FasterXML/jackson-module-scala

Duplicate fields with ScalaObjectMapper

オープン
#267 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Scala
スター
506
フォーク
138
平均マージ
3時間 6分
マージ済み PR(30日)
48

説明

When there is a `case class` with `BeanProperty`-annotated field, the following code sometimes generates JSON with duplicate fields. For example, `pId` field gets serialized twice, as `pId` and `pid`.

```
private val mapper = {
val objectMapper = new ObjectMapper with ScalaObjectMapper
objectMapper.registerModule(DefaultScalaModule)
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
objectMapper
}

def toJson[A <: AnyRef](a: A): String = {
mapper.writeValueAsString(a)
}
```

It's impossible to remove `BeanProperty` annotation, because it's needed by another library. Also it's impossible to set `BeanProperty` on every field and remove `ScalaObjectMapper`, as such changes are numerous and would likely result in other compatibility issues. What's the proper way to fix this problem?

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

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

評価

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

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

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