Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

JSON to XML: one root element for top-level arrays, and keep empty and nested arrays

Chiusa Adatta ai principianti
#204 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@anurag2787 ci sta già lavorando.

Dal 19/10/2026.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
next.js, typescript
Ambito
tooling

Direzione di ricerca

Inizia da toXML e dal relativo ramo per gli array in lib/json-utils.ts, poi esamina il test esistente di toXML in lib/__tests__/json-utils.test.ts. Aggiungi controlli sul testo prodotto per gli array al livello superiore, vuoti e annidati, e per i casi con oggetti invariati. Il lavoro è completato quando tutti i casi di accettazione elencati passano e l’output degli oggetti esistenti resta invariato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug good first issue hacktoberfest

The JSON formatter's XML conversion (toXML in lib/json-utils.ts) gives broken XML when the JSON is an array, and it drops data for empty and nested arrays:

JSON XML now
[1,2] two <rootItem> elements and no root element, which isn't well-formed XML
[] only the <?xml ...?> line, with no element at all
{"a":[]} an empty <root>, so a is gone
{"a":[[1,2],[3]]} three <aItemItem> siblings, so [1,2] and [3] can't be told apart

Objects, and arrays inside objects, are fine today: {"users":[{"id":1},{"id":2}]} gives two <user> elements inside <root>, and that should stay as it is.

Where to look

  • lib/json-utils.ts: toXML (line 571) and the array branch of render (lines 579 to 584)
  • lib/__tests__/json-utils.test.ts: only one test touches toXML today (line 100), so add a describe("toXML") block
  • app/(tools)/json-formatter/components/ConversionPanel.tsx (line 59) is where the tool calls it

Acceptance criteria

  • A top-level array gives one <root> element with the items inside, so [1,2] gives <root> with two <rootItem> children
  • An empty array gives an empty element: [] gives <root/>, and {"a":[]} gives <a/> inside <root>
  • An array inside an array gets its own element, so {"a":[[1,2],[3]]} gives two <aItem> elements, the first with two <aItemItem> children and the second with one
  • Output for objects, and for arrays of values or objects inside objects, doesn't change
  • Tests check the output text for each case above (please don't add an XML parser as a dependency)
  • npm run lint, npm run test and npm run build pass

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 #204 in the description.

Lingua principale
TypeScript
Stelle
1
Fork
9
Merge medio
9h 50m
PR unite (30g)
105

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codercops/toolbelt

Tutte le issue di codercops/toolbelt

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.