JSON Import Attributes Playground

Dodi’s price list imported as a module by this browser: what happens with no attribute, with the wrong MIME type, with the old assert, and when several…

Why it matters

A TypeError when importing JSON, assert suddenly becoming a SyntaxError, and a server sending the wrong type are the three most common dead ends. All three are clear once you know the attribute is a type request checked against the Content-Type, for safety.

The key idea

The type attribute is a contract: what arrives must be what was asked for

Common mistakes

Try it in this playground