JSON to XML: keys like `@type`, `$ref` or `bad key` turn into `<item>`
Los mantenedores suelen responder en 1 día
@AyanZahid-Code ya está trabajando en esto.
Desde el 20/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- json, typescript, xml
- Área
- tooling
Línea de trabajo
Start with sanitizeTag and its callers in lib/json-utils.ts, then extend the toXML tests beginning at line 113 in lib/__tests__/json-utils.test.ts. Implement the specified ASCII tag-name rules and verify scalar keys, arrays, empty keys, Unicode, and unchanged valid names without adding an XML parser. Run npm run lint, npm run test, and npm run build; all should pass. Note that linked pull requests 216 and 217 are closed and unmerged, so confirm the issue remains unclaimed before starting.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The JSON formatter's XML conversion (toXML in lib/json-utils.ts) writes each key as a tag name. When a key isn't a valid XML name, sanitizeTag (line 573) drops the whole key and writes item instead:
{"bad key": 1, "1x": 2, "@type": "Person", "$ref": "#/a"}
gives
<root>
<item>1</item>
<item>2</item>
<item>Person</item>
<item>#/a</item>
</root>
so there's no way to tell which value was which. It happens to keys with a space or a leading digit, and to the @ and $ keys that JSON-LD (@context, @type, @id) and JSON Schema ($schema, $ref) use all the time. An array under such a key loses its name too: {"my tags": ["a", "b"]} gives two <itemItem> elements.
What to do
Keep the key and change only what XML doesn't allow:
- replace every character that isn't an ASCII letter, digit,
_,-or.with_ - put
_in front if the result starts with a digit,-or. - an empty key stays
item
So bad key becomes bad_key, 1x becomes _1x, @type becomes _type, $ref becomes _ref and a:b becomes a_b. Keys that are fine today, like first-name, user.id and _id, don't change.
Stay with ASCII, even though XML allows many other letters in names. Parsers don't agree on which ones (Python's built-in parser rejects some that libxml2 accepts), and ASCII names work in all of them. So café becomes caf_. Today it becomes item.
Where to look
lib/json-utils.ts:sanitizeTag(line 573).toXMLuses it for keys (line 609), array items (line 591) and the root element (line 615), so array items follow the fixed name without extra work:{"my tags": ["a", "b"]}should give two<my_tag>elements.lib/__tests__/json-utils.test.ts: thetoXMLtests start at line 113
Acceptance criteria
-
bad key,1x,@type,$ref,a:band-agive<bad_key>,<_1x>,<_type>,<_ref>,<a_b>and<_-a> -
first-name,user.idand_iddon't change, an empty key gives<item>, andcafégives<caf_> -
{"my tags": ["a", "b"]}gives two<my_tag>elements - Tests check the output text for each case above (please don't add an XML parser as a dependency)
-
npm run lint,npm run testandnpm run buildpass
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off develop, and open your PR against develop with Closes #214 in the description.
- Lenguaje dominante
- TypeScript
- Estrellas
- 1
- Forks
- 9
- Merge medio
- 10 h 24 min
- PR fusionados (30 d)
- 93
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
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 codercops/toolbelt
-
bug good first issue hacktoberfest
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
bug good first issue hacktoberfest
Dificultad 2/5 1-3 horas Aptitud para principiantes 94/100
Los mantenedores suelen responder en 1 día
-
bug good first issue hacktoberfest
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
Los mantenedores suelen responder en 1 día
-
Stop the JSON formatter's Find bar from typing into the JSONPosiblemente ocupada @kudala-bharani la tomó hace 2 días. Abiertobug hacktoberfest help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
codercops/toolbelt#121 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
JSON formatter: a duplicate key crashes the whole toolPosiblemente ocupada @lb1192176991-lab la tomó hace 1 día. Abiertobug good first issue hacktoberfest
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
codercops/toolbelt#218 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de codercops/toolbelt
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
endora-commerce/endora-commerce#397 ·
Los mantenedores suelen responder en 1 día
-
level/task
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
wazuh/wazuh-dashboard-plugins#9472 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
Los mantenedores suelen responder en 1 día
-
ready-for-agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
xavxyz/bei-shan-lin-shui#57 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
opennextjs/opennextjs-cloudflare#1461 ·
Los mantenedores suelen responder en 1 día