XML repeated elements: when to use arrays in JSON output

TL;DR: Fix XML validity first, then convert XML to JSON locally (no upload).

XML expresses lists by repeating a tag. JSON expresses lists with arrays. The tricky part is consistency: one item vs multiple items can produce different shapes.

Why “sometimes array, sometimes object” is painful

If your JSON output uses an object when there’s one element and an array when there are multiple, every consumer has to write branching logic. This creates bugs in spreadsheets, scripts, and API pipelines.

Practical mapping rule

  • If a tag appears more than once under the same parent → represent it as an array.
  • If it appears once → represent it as a single object or string.
  • If you control the output contract → prefer always-array for known “list” tags.

How to keep output stable

For stable downstream code, document which tags are lists. If you can’t, normalize after conversion: wrap single objects into arrays for expected list fields. This is especially useful for feeds where “one item” is common during tests.

Practical checklist (fast)

If you’re stuck, use this quick checklist to narrow the problem before you try “random fixes”. Start by validating the input format (syntax first), then confirm shape expectations (array vs object, headers vs rows). Convert a small sample, inspect the output, and only then export the full result.

  • Validate: confirm the input is strict JSON/XML/CSV (no stray characters).
  • Confirm shape: arrays vs objects; headers vs row lengths; repeated tags vs arrays.
  • Test a sample: first 20–50 rows/items are enough to detect parsing issues.
  • Export: copy/download the output and re-check it in the consumer (script/spreadsheet/API).

This workflow is privacy-first by design: All processing happens locally in your browser. Files are never uploaded.

FAQ

What about mixed content (text + children)? Store text under a dedicated key (like #text) and keep children separate.

Do namespaces affect array detection? They can: prefixes make tag names look different. Ensure consistent naming before grouping.

Trust note: All processing happens locally in your browser. Files are never uploaded.

Local verification snippet

Run a quick local check before export/convert:

const doc = new DOMParser().parseFromString(xmlText, 'application/xml');
const err = doc.querySelector('parsererror');
if (err) throw new Error(err.textContent || 'Invalid XML');
console.log('XML is well-formed');
Privacy & Security
All processing happens locally in your browser. Files are never uploaded.

Quick fix checklist

  • Reproduce the error on a minimal input.
  • Check type/format and field mapping.
  • Apply the smallest safe fix.
  • Validate on production-like payload.

Related by intent

Useful follow-up pages selected from real search impressions and no-click opportunities.

No-click fix: winner java xml repeated elements arrays workflows batch jobsNo-click fix: winner node xml repeated elements arrays alternatives auth flowNo-click fix: winner compare java xml repeated elements arrays performance api gatewayRelated fix: neighbor csharp rust serde json map a string col 2 workflows data importRelated fix: neighbor csharp rust serde json string abc unit col 1 workflows data importRelated fix: neighbor csharp rust serde json boolean true a string col 1 workflows data importRelated fix: neighbor csharp csharp stj could not be converted system int32 id workflows webhooksRelated fix: neighbor csharp csharp stj could not be converted system int32 data workflows webhooksRelated fix: neighbor csharp csharp stj could not be converted system int64 data workflows webhooksRelated fix: neighbor go csharp stj could not be converted system string token runbooks data importRelated fix: neighbor csharp csharp stj could not be converted system double data workflows webhooksRelated fix: neighbor csharp csharp stj could not be converted system int32 id workflows api gatewayRelated fix: neighbor csharp csharp stj could not be converted system int32 id workflows data importRelated fix: neighbor csharp csharp stj could not be converted system decimal data workflows webhooksRelated fix: neighbor csharp csharp stj could not be converted system double id workflows data importRelated fix: neighbor csharp csharp stj could not be converted system guid payload workflows webhooksRelated fix: neighbor csharp csharp stj could not be converted system int32 user id runbooks webhooksRelated fix: neighbor csharp csharp stj could not be converted system string status runbooks webhooksRelated fix: neighbor csharp csharp stj could not be converted system string token workflows webhooksRelated fix: neighbor csharp csharp stj could not be converted system int32 data workflows api gateway

Next pages to check

Closest crawled pages without impressions yet. Added to speed first-impression conversion.

neighbor csharp csharp stj could not be converted system int32 items 0 id checklists ananeighbor csharp csharp stj could not be converted system int32 items 0 id checklists edgneighbor csharp csharp stj could not be converted system int32 items 0 id workflows enteneighbor csharp csharp stj could not be converted system int32 user id checklists analytneighbor csharp go json cannot unmarshal bool into field user id type int troubleshootinneighbor python go json cannot unmarshal string into field payload user type string runbneighbor csharp csharp newtonsoft error converting 123 system guid user id runbooks analneighbor csharp csharp newtonsoft error converting 123 system guid user id workflows ananeighbor csharp csharp newtonsoft error converting 123 system guid user id workflows apineighbor csharp csharp newtonsoft error converting 123 system guid user id workflows webneighbor csharp csharp newtonsoft error converting 123 system int32 user id workflows apneighbor csharp csharp newtonsoft error converting 123 system int32 user id workflows daneighbor csharp csharp newtonsoft error converting 123 system int32 user id workflows weneighbor csharp csharp newtonsoft error converting 123 system int64 items 0 id workflowsneighbor csharp csharp newtonsoft error converting 123 system int64 items 0 id workflowsneighbor csharp csharp newtonsoft error converting 2026 02 17 system boolean id workflowneighbor csharp csharp newtonsoft error converting false system datetime value workflowsneighbor csharp csharp newtonsoft error converting infinity system int32 items 0 id runb