A sprite sheet maker can produce a PNG that opens correctly and metadata that parses successfully, yet still leave an ambiguous delivery. The overlooked boundary is between the JSON source text and the object your validator receives.
Consider a strict delivery rule: each frame name must identify exactly one stored rectangle. This tiny constructed source violates it:
{"frames":{"idle":{"x":0,"y":0,"w":2,"h":2},"idle":{"x":2,"y":0,"w":2,"h":2}}}
Both rectangles fit a four-by-two image. A conventional last-value-wins decoder can retain only the second idle. A later bounds check passes; a uniqueness check over dictionary keys also passes. Neither can discover the definition that disappeared during decoding.
Put the first gate before the dictionary
For a Python validation job, the standard decoder can expose incoming member pairs:
import json
def unique_object(pairs):
result = {}
for name, value in pairs:
if name in result:
raise ValueError(f"duplicate JSON member: {name}")
result[name] = value
return result
source = '{"frames":{"idle":{},"idle":{}}}'
json.loads(source, object_pairs_hook=unique_object)
This deliberately raises. The hook applies to every object in this declared strict contract. It is not a claim that all JSON readers must reject duplicates by default, and it does not turn every atlas format into the same schema.
Keep source validity and importer validity separate
After source decoding, validate the selected format: integer pixel coordinates if that format requires them, positive extents, real image bounds, frame references, page names, and supported rotation or trim features. An array format needs an explicit duplicate-ID check on its entries; array entries are not object member names.
Then test the receiving loader with a diagnostic frame. A structurally valid map can still describe the wrong traversal or an unsupported convention. Reject bad input with a frame identity and reason rather than silently shortening a rectangle or substituting frame zero.
Add a failure that proves the gate is wired in
Keep a valid file and the duplicate-member source in your repository. The valid file should pass; the duplicate source should make the validation command exit unsuccessfully. If both pass, investigate decoding and error propagation before trusting a green CI badge.
This is an acceptance boundary for an existing export pipeline. It is not evidence that a particular generator emits duplicate keys, nor does it judge the motion in the frames. The accompanying FrameSprite guide includes bounded reproducible controls for typed fields and source-member validation.
Further reading
Read the strict atlas metadata checks
Check the array-versus-object ordering contract
Browse the workflow guide collection
FrameSprite team product education. Prepared with AI assistance and editorial review. Numerical examples are constructed checks, not model benchmarks or customer results.
Top comments (0)