I'm finding that I'm having a hard time wrapping my head around the
rules of ASON. For example, one of your examples has this:// The following are all the same
"Jim" 42 "Banker";
"Jim" {age 42 occupation "Banker"}
{name "Jim" age 42 occupation "Banker"}I find the fact that the second and third are equivalent to be very
confusing.
BTW, thanks for mentioning your SDL grammar, I'm looking over it.
I agree that nameless fields be confusing. This example was merely a demonstration of how nameless object fields work, however, it is up to the application to specify what fields can become nameless. In most cases nameless fields should be avoided to prevent this confusion. In the case of a dub package file, I would probably allow any "name" field such as "dependency name", or "subPackage name", or "configuration name" to become nameless, but that's about it.
dependency {name "vibe-d" version ">=1.0.0"}
// OR
dependency "vibe-d" {version ">=1.0.0"}
Also, at times, it seems like ASON's semantics are dependent on the D
struct being filled. Or am I mistaken about that?How are these two lines interpreted by ASON?:
a b c
a b c d
What is the equivalent JSON for those? Is it:
"a": {"b": "c"}
"a": {"b": ["c", "d"]}or:
"a": "b", "c": null
"a": "b", "c": "d"or:
"a": "b", "c": {
"a": "b", "c": "d"
}
or:
"a": "b", "c": "a", "b": "c", "d": null
Or something else?
Yes you are correct! ASON's semantics are dependent on the application. That's where the name "Application Specific" came from. The following features make the text "Application Specific"
- optional colons/commas
- omitting root level braces or brackets
- Nameless object fields.
I've noticed that in most applications it's unnecessary to specify the structure of the data you are representing because the application already knows what kind of data it is expecting. This concept is what makes ASON unique from other JSON variants. This is the main concept I wanted to get people's opinions on. There are advantages and disadvantages to it. Thanks for taking the time to read it and understand what makes it unique.