0

I have found JSON and YAML both lacking.

I wish to do something like this (in YAML):

nodes:
  node: "name for my node":
    - data
    - for 
    - this
    - node

(in JSON):

{"nodes":
   {"node":"name for my node": {
     ["data","for","this","node"] 
   }}
}

But these are both invalid in those data serialization languages.

Does anyone know of a data serialization language where you can use an object as the name for an object, basically? I think it's stupid that you can't do it in YAML, though I could forgive JSON since it is designed to be simple as opposed to being flexible.

CommaToast
  • 11,370
  • 7
  • 54
  • 69

1 Answers1

0

Actually, YAML can do that. Try the complex-key syntax (see the bottom of spec section 2.2)

nodes:
  ? node: name for my node
  : - data
    - for
    - this
    - node

That's a map with a single key, used as a key. If you perhaps were after a list as the key:

nodes:
  ? - nodename1
    - nodename2
  : - data
    - for
    - this
    - node
  • Can you please pay more attention to the suggested edits you're reviewing? Both the "new" URLs in [this](http://stackoverflow.com/review/suggested-edits/2602828) and [this](http://stackoverflow.com/review/suggested-edits/2602835) edit do not work either. Can you please check in future? – Matt Jul 28 '13 at 11:47