Back to all articles

Operations · Guide

One order, two quantities: do not let AI choose for the parser

A local Python experiment shows why duplicate JSON names need rejection before parsing loses the conflict.

One order, two quantities: do not let AI choose for the parser

Original AAHouse explanatory video. AI-assisted conceptual visuals and neural narration; original music.

English transcript · Simplified Chinese Mandarin transcript · Taiwan Mandarin transcript · Macao Cantonese transcript

Pause this import

A fictional pottery shop receives {"quantity":12,"quantity":120}. Its AI assistant says the format check passed and the order can ship. But does the customer want twelve mugs or one hundred twenty? This is not a contest to pick the more plausible answer. One object contains the quantity name twice. Keep the order in review before either interpretation reaches fulfillment.

Synthetic order: ONE object
Synthetic order: ONE object
  • quantity: 12
  • quantity: 120
  • Pause before guessing

Unchanged original source explanatory diagram.

Why a green light cannot choose the quantity

RFC 8259 recommends unique names within a JSON object. It describes differing receiver behavior for duplicates: keeping the last pair, reporting an error, or preserving all pairs.[1] Python documents a concrete case: its default decoder retains the final value.[2] Successful parsing therefore describes one parser’s behavior, not a settled business meaning.

Parsing is not meaning
Parsing is not meaning
  • Some retain the last value
  • Others reject / preserve all

Unchanged original source explanatory diagram.

A tiny local experiment

In an isolated environment, we passed that synthetic text to Python’s default decoder and obtained quantity 120. An object_pairs_hook that checks for repeated names rejected it instead. No shop or shipping system was connected, and this does not establish every language’s behavior. The important observation: once the first parse discards a value, a later check of that dictionary cannot see the original conflict.

Local Python experiment
Local Python experiment
  • Default decoder: 120
  • Duplicate check: rejected

Unchanged original source explanatory diagram.

Reject before information disappears

We recommend detecting repeated names per object while parsing the original JSON at intake, before field, range and business-approval checks. Use a complete parser rather than a regular expression; cover nested objects too. The same name in two separate objects is not this kind of duplicate. For rejected data, retain a controlled source reference and error location, assign a correction owner, and avoid copying complete customer records into logs.

Raw JSON → duplicate check
Raw JSON → duplicate check
  • Then field / range checks
  • Business approval → fulfillment

Unchanged original source explanatory diagram.

Four questions for the handoff

Our acceptance checklist asks whether a normal single field passes, a repeated quantity in one object is rejected, a nested duplicate is rejected, and two separate objects with their own quantity remain valid. Also verify that rejection causes no warehouse action and that a person can locate the order needing correction. Beyond the local parsing experiment above, these workflow checks are recommendations, not customer-system tests. AI can explain the ambiguity; it cannot guess the customer’s order.

Normal field: pass
Normal field: pass
  • Same-object / nested: reject
  • Separate objects: allow

Unchanged original source explanatory diagram.

Need help turning an idea into a pilot?

Discuss your workflow

Sources and further reading

Editorial approach

AI-assisted original writing, checked against linked public sources. Practical recommendations and illustrative scenarios are editorial analysis, not reported client results. Source dates and product details may differ from this collection’s preparation date.