Allow custom prefix for attributes name
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- java
- Domaine
- backend-api-design
Piste de recherche
Commencez par suivre XMLMapper et le MapSerializer existant pour le traitement entrant et sortant des entrées de map, puis identifiez le chemin de désérialisation correspondant. Le travail est terminé lorsqu’un préfixe d’attribut configurable distingue les attributs des éléments, prend en charge le comportement de compatibilité pour null et pour un préfixe vide, et gère l’exemple XML fourni dans les deux sens.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Java
- Étoiles
- 636
- Forks
- 250
- Merge moyen
- 7 h 10 min
- PR mergées (30 j)
- 8
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de FasterXML/jackson-dataformat-xml
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
FasterXML/jackson-dataformat-xml#931 · 3 commentaires ·
-
XmlMapper with `FAIL_ON_UNKNOWN_PROPERTIES` fails on whitespace-only elementPeut-être pris @arimu1 l’a pris il y a 89 jours. Ouverteto-evaluate
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
-
3.x
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
FasterXML/jackson-dataformat-xml#787 · 1 commentaire ·
Toutes les issues de FasterXML/jackson-dataformat-xml
Issues similaires
-
Cleanup: restore the interrupt flag in AiFailureAnalyzerPeut-être pris @Rishankgupta08 l’a pris aujourd’hui. Ouvertegood first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
seleniumboot/selenium-boot#258 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
dense-analysis/ale#5181 ·
-
bug subsystem:agent-harness triage
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
ShaftHQ/SHAFT_ENGINE#8043 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
johanhaleby/occurrent#1505 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour