jsonnorm / JSON arrays without false joins

Technical guide · relational shape

Keep independent JSON arrays from creating false relationships.

When an order has items and payments, choose one array to create repeated rows and keep the other as JSON. This preserves what the source actually says.

The difficult example: two independent child arrays

There are two items but two payments. Pairing each item with each payment would create four rows with relationships the source never asserted. jsonnorm creates rows from one array and keeps the other as JSON.

Input JSON

[{
  "orderId": 42,
  "items": [{ "sku": "S1", "qty": 2 }, { "sku": "S2", "qty": 1 }],
  "payments": [{ "method": "card", "amount": 19.99 }, { "method": "coupon", "amount": 5.00 }]
}]

Resulting CSV (items exploded)

orderId,items.sku,items.qty,payments
42,S1,2,"[{""method"":""card"",""amount"":19.99},{""method"":""coupon"",""amount"":5.00}]"
42,S2,1,"[{""method"":""card"",""amount"":19.99},{""method"":""coupon"",""amount"":5.00}]"

One array per conversion can create repeated rows. Keep other arrays as JSON or join their values.

How to choose the next normalization step

  • Choose one array to create repeated rows.
  • Keep an independent array as JSON when its items do not pair by position with the selected array.
  • Join primitive values when a single cell is the intended result.

Preview the safe result: /items creates rows and /payments stays as JSON.

Try this array conversionOpen in examples