News for hackers. Stuff that matters.
Re:A Brief Defense of XML by electroly on Friday January 06, 2023 @10:23AM (#34275639)
The quotes in XML don't make it a string; in the XML schema you can specify the type (and so much more). JSON has a lot of benefits but it absolutely loses this particular comparison. XML schemas will give you all the type information and automatic validation you can swallow. Typing in XML is far richer than in JSON. There's even a date type!
Re:A Brief Defense of XML by smitty1e on Friday January 06, 2023 @07:58PM (#34283749)
You mean an .xsd?

JSON has .avro, I thought.

It's all data. Validation logic is sold separately.

Re:A Brief Defense of XML by dragonwriter on Friday January 06, 2023 @08:06PM (#34283833)
> The quotes in XML don’t make it a string; in the XML schema you can specify the type (and so much more). JSON has a lot of benefits but it absolutely loses this particular comparison.

JSON, like XML, has several schema languages, which have widely-available libraries for generating host language typings, validation, etc.

> Typing in XML is far richer than in JSON. There’s even a date type!

JSON Type Definition has timestamp, JSON Schema has date, date-time, time, and duration.

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.
Re:A Brief Defense of XML by mdaniel on Saturday January 07, 2023 @02:11PM (#34291494)
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
    }
Re:A Brief Defense of XML by WorldMaker on Friday January 06, 2023 @08:13PM (#34283895)
JSON Schemas exist too. The most common being the eponymously named type: https://json-schema.org/

I've seen JSON schemas describe things like date types and plenty more. If you are including schema metadata alongside XML, then for a fair fight you can include JSON schemas, too.