Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: JSON with names?
2 points by kizer on Oct 9, 2018 | hide | past | favorite | 1 comment
I've been thinking about the differences between XML and JSON. A key constraint in XML is that all elements are named; in JSON, all objects are anonymous by default.

Of course, it's simple to add a "name" or "type" field. However, the name of the object ought to be denoted differently than its contents, IMHO.

I propose a small change to the JSON specification, where a "name" can be optionally placed before the opening bracket of an object or array:

    "employee": Employee {
    ...
    }, 
    "fibonacci": Sequence [1, 2, 3, 5]

Any thoughts? Would this burden parsing or serialization?


> Any thoughts? Would this burden parsing or serialization?

It's solving a problem we don't have.

> Of course, it's simple to add a "name" or "type" field. However, the name of the object ought to be denoted differently than its contents, IMHO.

Why?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: