Skip to content

Should my application accept JSON commands containing the same property twice?

Reject duplicate property names in sensitive JSON command envelopes at your application's ingestion boundary when they could affect approval or execution. Different JSON processing paths can interpret repeated names differently. Do not approve one value in a preview while the dispatch serializer later uses another.

TEST THE CUSTOMER API CONTRACTAISwapLab team · Editorial methodUpdated 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Identify sensitive commands; Normalize one accepted envelope; Test parser disagreement.
Workflow diagram: Identify sensitive commands → Normalize one accepted envelope → Test parser disagreement. Read the article for evidence and limits.

Ambiguity undermines reviewed intent

RFC 8259 recommends unique object names and describes interoperability issues when names repeat. A normal JSON.parse result may already have discarded the evidence of duplication. This is an application input policy; do not claim AISwapLab exposes a duplicate-member validator.

What to do next

  1. 01

    Identify sensitive commands

    Apply the policy to generation approvals and configuration changes where repeated model, size or spending fields would create ambiguity. Use an ingestion parser capable of detecting duplicates before converting the body into an ordinary object.

  2. 02

    Normalize one accepted envelope

    After validation, construct a fresh allowlisted command object from the accepted fields. Use that same immutable representation for preview, approval identity and dispatch so multiple parsers cannot reinterpret the original raw body.

  3. 03

    Test parser disagreement

    Send a local fixture with repeated size or max_credits properties and verify a clear rejection. Also test nested command objects if your application accepts them, without forwarding malformed probes to the production generation endpoint.

A concrete example

Illustrative example: a local command contains two size members with different values. The application refuses it before preview and dispatch, so the reviewer cannot see the first size while the final serializer silently uses the last.

Before you call it ready

  • Duplicate sensitive names are rejected early.
  • Approval and dispatch use one normalized object.
  • Tests run against the local ingestion boundary.

A locally executed, reproducible check

The default parser discards duplicate-member evidence, while a pair hook can reject the original duplicate.

We executed this exact synthetic fixture on November 16, 2026 with Python 3.12.10 and SQLite 3.49.1. It ran locally with no network requests, account data or model generation. The recorded output below is an observation from that environment, not a platform benchmark. Copy the code into a separate Python file to repeat it in a suitable local environment; compare the mechanism and check your runtime version.

python
import json
raw='{"size":"1K","size":"4K"}'
print('default parser:',json.loads(raw))
def unique(pairs):
    out={}
    for key,value in pairs:
        if key in out:raise ValueError('duplicate member: '+key)
        out[key]=value
    return out
try:
    json.loads(raw,object_pairs_hook=unique)
except ValueError as error:
    print('pair-aware parser:',error)

Recorded output and interpretation

This demonstrates Python’s parser and an illustrative local policy, not universal JSON parser behavior or a claim about an accepted AISwapLab request. Preserve the original pair sequence until duplicate validation finishes.

A matching local output establishes only the illustrated library or database behavior under these inputs. It does not certify a production integration. Preserve the approved action, authorization boundaries and current AISwapLab request contract when applying the idea.

text
default parser: {'size': '4K'}
pair-aware parser: duplicate member: size

When to stop or choose another method

Stop treating a successfully parsed object as proof that the original command was unambiguous when duplicate-member detection matters to execution.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation