FasterXML / FasterXML/jackson-dataformat-xml

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

Offen
#217 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
631
Forks
246
Ø Merge
7 T. 9 Std.
Gemergte PRs (30 T.)
13

Beschreibung

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 :

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

The converted XML is as follows

```xml




3EfXiRbNk517MHY
0amcNeP5QhXnY9x3Ykkj5TScqoTQF
yy

EUR
1462216



```

The requested output is as follows:

```xml




3EfXiRbNk517MHY
0amcNeP5QhXnY9x3Ykkj5TScqoTQF
yy
1462216


```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.