Allow custom prefix for attributes name
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- java
- Área
- backend-api-design
Línea de trabajo
Comienza rastreando XMLMapper y el MapSerializer existente para el procesamiento de entrada y salida de las entradas del mapa; después, identifica la ruta de deserialización correspondiente. Se considera terminado cuando un prefijo de atributos configurable distingue los atributos de los elementos, admite el comportamiento de compatibilidad para null y para un prefijo vacío, y maneja el ejemplo XML proporcionado en ambas direcciones.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Java
- Estrellas
- 636
- Forks
- 250
- Merge medio
- 7 h 10 min
- PR fusionados (30 d)
- 8
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de FasterXML/jackson-dataformat-xml
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
FasterXML/jackson-dataformat-xml#931 · 3 comentarios ·
-
XmlMapper with `FAIL_ON_UNKNOWN_PROPERTIES` fails on whitespace-only elementPosiblemente ocupada @arimu1 la tomó hace 89 días. Abiertoto-evaluate
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
-
3.x
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
FasterXML/jackson-dataformat-xml#787 · 1 comentario ·
Todos los issues de FasterXML/jackson-dataformat-xml
Issues similares
-
Cleanup: restore the interrupt flag in AiFailureAnalyzerPosiblemente ocupada @Rishankgupta08 la tomó hoy. Abiertogood first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
seleniumboot/selenium-boot#258 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
dense-analysis/ale#5181 ·
-
bug subsystem:agent-harness triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ShaftHQ/SHAFT_ENGINE#8043 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
johanhaleby/occurrent#1505 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día