Allow preserving "is-attribute" with JsonNode to write output as attribute value

オープン
#217 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
java
領域
backend

調査の方向性

まず、報告に示されている JSON と XmlMapper の write メソッドで問題を再現し、その後 JsonNode の処理における XML シリアライズの経路を調べます。完了条件は、OrgnlIntrBkSttlmAmt のような選択されたネストされたフィールドが Ccy を XML 属性として保持し、残りの JsonNode 構造が要素として書き込まれることです。

索引モデルが issue の本文から書いたものです。

説明

I want to map a JsonNode to a XML. If I directly call XmlMapper write methods, this converts all the SubNode's of JsonNode as XMLElement which is fine.

But I want one of the field/subfield convert as XMLAttribute.

Is there a way to tell the mapper 'this node is not element, please convert it as attribute?'

Check the OrgnlIntrBkSttlmAmt field below (XML and json format is not preserved, sorry for that)

A sample JSON file is as follows :

{
    "FIToFIPmtCxlReq": {
        "Undrlyg": [
            {
                "TxInf": [
                    {
                        "CxlId": "3EfXiRbNk517MHY",
                        "OrgnlInstrId": "0amcNeP5QhXnY9x3Ykkj5TScqoTQF",
                        "OrgnlIntrBkSttlmAmt": {
                            "Ccy": "EUR",
                            "Value": 1462216
                        }
                    }
                ]
            }
        ]
    }
}

The converted XML is as follows

<?xml version='1.1' encoding='UTF-8'?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.056.001.01">
	<FIToFIPmtCxlReq>
		<Undrlyg>
			<TxInf>
				<CxlId>3EfXiRbNk517MHY</CxlId>
				<OrgnlInstrId>0amcNeP5QhXnY9x3Ykkj5TScqoTQF</OrgnlInstrId>
				<OrgnlEndToEndId>yy</OrgnlEndToEndId>
				<OrgnlIntrBkSttlmAmt>
					<Ccy>EUR</Ccy>
					<Value>1462216</Value>
				</OrgnlIntrBkSttlmAmt>
			</TxInf>
		</Undrlyg>
	</FIToFIPmtCxlReq>
</Document>

The requested output is as follows:

<?xml version='1.1' encoding='UTF-8'?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.056.001.01">
	<FIToFIPmtCxlReq>
		<Undrlyg>
			<TxInf>
				<CxlId>3EfXiRbNk517MHY</CxlId>
				<OrgnlInstrId>0amcNeP5QhXnY9x3Ykkj5TScqoTQF</OrgnlInstrId>
				<OrgnlEndToEndId>yy</OrgnlEndToEndId>
				<OrgnlIntrBkSttlmAmt Ccy="EUR">1462216</OrgnlIntrBkSttlmAmt>
			</TxInf>
		</Undrlyg>
	</FIToFIPmtCxlReq>
</Document>
主要言語
Java
スター
636
フォーク
250
平均マージ
7時間 10分
マージ済み PR(30日)
8

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

FasterXML/jackson-dataformat-xml のほかの issue

FasterXML/jackson-dataformat-xml の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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