Allow custom prefix for attributes name
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- java
調査の方向性
まず XMLMapper と既存の MapSerializer を追跡して、マップエントリの入力および出力処理を確認し、次に対応するデシリアライズ経路を特定します。設定可能な属性プレフィックスによって属性と要素を区別し、null と空のプレフィックスに対する互換動作をサポートし、提示された XML 例を両方向で処理できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
The default behavior of the XML deserialization, when reading into non-bean objects is to treat attributes the same way as elements. On serialization, I could not find way to generate attributes - all hash map entries were converted into objects. The only way I found to be able to tell the difference between elements and attributes in the outbound was to write a custom serializer, still working on trying to get this done with inbound serializer.
Example:
var mapper = new XMLMapper();
Object value = mapper.readValue("<DATA FOO="BAR"> <COLOR> WHITE </COLOR> </DATA>
The resulting object will be set of LinkedHashMap, with no obvious way to tell the different between the attributes and the elements.
(LinkedHashMap) {
"FOO": "BAR",
"COLOR": "WHITE",,
}
Would like to suggest/ask for a new setting on the XMLMapper that will allow specifying a prefix for attributes. On the inbound, each attribute will be stored with the prefix inside the key. In my case, I'm using '@' as prefix, there the example above will result in
var mapper = new XMLMapper();
Object value = mapper.readValue("<DATA FOO="BAR"> <COLOR> WHITE </COLOR> </DATA>
// Define Custom Prefix
mapper.setAttributPrefix("@");
Result:
(LinkedHashMap) {
// FOO is prefixed with '@'
"@FOO": "BAR",
"COLOR": "WHITE",,
}
For the Serializer - same logic in reverse. If map key starts with the designated prefix it will be converted into an attribute (with the prefix removed). For backward compatibility:
- If the prefix is NULL (or not set), current logic remain
- If the prefix is "" (empty string), every map entry will be converted into attribute with the same name (subject to the text attribute, which already has special handling).
While the custom serializer was short to write - It took some googling/effort to write, and I believe it's not as robust as the built in logic that is currently implemented in the MapSerializer. Will address lot of use cases when it's critical separate attribute/elements, without having to predefined beans.
- 主要言語
- Java
- スター
- 636
- フォーク
- 250
- 平均マージ
- 7時間 10分
- マージ済み PR(30日)
- 8
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
FasterXML/jackson-dataformat-xml のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
FasterXML/jackson-dataformat-xml#931 · コメント 3 件 ·
-
XmlMapper with `FAIL_ON_UNKNOWN_PROPERTIES` fails on whitespace-only element対応中かも @arimu1 が 89 日前に担当しました。 オープンto-evaluate
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
-
3.x
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
FasterXML/jackson-dataformat-xml#787 · コメント 1 件 ·
FasterXML/jackson-dataformat-xml の issue をすべて見る
似ている issue
-
Cleanup: restore the interrupt flag in AiFailureAnalyzer対応中かも @Rishankgupta08 が今日担当しました。 オープンgood first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
seleniumboot/selenium-boot#258 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
dense-analysis/ale#5181 ·
-
bug subsystem:agent-harness triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ShaftHQ/SHAFT_ENGINE#8043 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
johanhaleby/occurrent#1505 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信