You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I've faced an issue working with XML documents (deserialization, modifying, serialization): from JsonNode I can't serialize XML with attributes. Attributes become regular JsonNode fields after deserialization and then serialized as child tags.
Kindly asking to consider adding new Feature (both for deserialization and serialization, disabled by default) to mark attribute field names with special prefix symbol (for example ampersand or underscore if ampersand may break something) during deserialization and, if new Feature enabled, serialize fields with this prefix to XML as attributes of parent tag (removing prefix before serialization), not as child tags.
The text was updated successfully, but these errors were encountered:
I think that ability to "decorate" attribute names at streaming level -- and not just for JsonNode -- would probably be useful thing. I probably won't have time to do work on this right now, but could help someone if they wanted to.
Support, if any, should probably be enabled/disabled with 2 new features: one for reading (FromXmlParser.Feature) and another for writing (ToXmlGenerator.Feature).
I guess this should work something like:
When reading, attribute names would be mutated to have leading @, exposed for JsonToken.FIELD_NAME
When writing, if (and only if) JsonToken.FIELD_NAME being written has @ prefix, that'd be stripped and value output as attribute.
I suspect there would be some challenges due to use of incremental generator: all attributes need to be written before any elements. So not 100% sure it would actually work as expected.
Also, if there is a property with multiple attributes and a text, it would be great to group them together and put a new key for the actual text of the property. I think this tool does a great job at converting XML to JSON while preserving attribute/text when necessary.
cowtowncoder
changed the title
XML attributes processing
Support retaining of XML attribute-ness with JsonNodeFeb 2, 2024
Hi!
I've faced an issue working with XML documents (deserialization, modifying, serialization): from JsonNode I can't serialize XML with attributes. Attributes become regular JsonNode fields after deserialization and then serialized as child tags.
Kindly asking to consider adding new Feature (both for deserialization and serialization, disabled by default) to mark attribute field names with special prefix symbol (for example ampersand or underscore if ampersand may break something) during deserialization and, if new Feature enabled, serialize fields with this prefix to XML as attributes of parent tag (removing prefix before serialization), not as child tags.
The text was updated successfully, but these errors were encountered: