Skip to main content

2 posts tagged with "schemas"

View All Tags

The Problem With JSON Schema (And What We Did Differently)

CJ Cummings
Creator and maintainer of Stof, co-founder & CEO of Limitr

JSON Schema's real limitation isn't its syntax. It's that a schema is always a second document describing a first one, and nothing keeps the two in agreement. Add a field to your data, forget the schema, and nothing tells you.

Stof takes a different approach: #[schema(...)] puts the rule on the field it protects, in the same document. There's no second file to fall out of sync.

We Deserve Better Than JSON as a DSL

CJ Cummings
Creator and maintainer of Stof, co-founder & CEO of Limitr

It always starts simply. You need a config, and you want to keep it simple this time. What's simpler than JSON? Some keys, some nesting, done.

Six months later the file looks like this:

{
"timeout": "5m",
"memory": "2GB",
"retries": "{{ env.CI ? 5 : 2 }}",
"url": "${PROTOCOL}://${HOST}:${PORT}"
}

Four values, three of which are secretly something else. "5m" is a duration someone has to parse. "2GB" is a size someone has to parse, and whether that's 2000 MB or 2048 MiB depends on which library parses it. The other two are expressions in a template language you invented, which a new hire has to be told about because nothing in the file says so.