Re:A Brief Defense of XML
by int_19h on Friday January 06, 2023 @08:49PM
(#34284155)
The nice thing about XML being an extensible markup language is that schemas (and metadata like xsi:type) could be easily written inline, making the document fully self-contained.
[ Parent
| on HN ]
I haven't personally tried such a stunt, but I'd bet it's possible to do that with JSON Schema, too, if the schema resolver tolerates the same self-references style in `$schema`. My experience with the tooling is "lol, yeah right" but shrug seems reasonable
{
"$schema": "#/$theSchema",
"$theSchema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "MySchema",
"type": "object",
"properties": {
"productId": {
"description": "The unique identifier for a product",
"type": "integer"
},
"productName": {
"description": "Name of the product",
"type": "string"
},
"price": {
"description": "The price of the product",
"type": "number",
"exclusiveMinimum": 0
}
}
},
"productId": 1,
"productName": "An ice sculpture",
"price": 12.50
}