▲ | IshKebab 4 days ago | |||||||
It solves the important problems that XML solved, without the mistakes. What is it missing? I think only namespacing, but that isn't really necessary in JSON because it isn't a document format where arbitrary elements can appear in arbitrary places. I have never once needed namespacing in JSON. Schemas... well there's JSON schema which is ok I guess. But in reality you probably don't want that either. Schemas are useful for IDEs and linters but that's it. Normally you validate a JSON file by parsing it, e.g. with Pydantic or Serde or Zod. The biggest missing feature from XML that JSON should have had is comments! Yes it was a mistake to omit them. | ||||||||
▲ | _heimdall 3 days ago | parent [-] | |||||||
Validating JSON with third party runtime libraries like zod is only necessary because JSON doesn't support schemas though. There's nothing wrong with those libraries, they solve a real problem but the problem is in JSON itself. The whole point of REST was to allow visitors to not only see the response to a request but to also be able to understand both the semantics and the functionality of it. Think HTML - it would be comparatively useless if HTML could only contain structured data with meaning, semantics, or schemas. Anchor tags, buttons, and forms are semantic and tell the user not only what a piece of text is but how they can interact with it. With JSON you have to know the shape of requests supported, the shape of data returned, and how to use that data to make other requests. | ||||||||
|