hoodwink.d enhanced
RSS
2.0
XHTML
1.0

RedHanded

YaySON #

by why in cult

Wow, the YAML-Core list is aflame with a conquest to get JSON to become a subset of YAML. The differences have historically been very, very minor. But tough to solve, given the aims of both languages. Oren Ben-Kiki suddenly piped up this week with some ideas and the TrinitY have been bouncing ideas around since.

Basically, the differences have been:

  1. Colon cramping:
    • In YAML hashes, the colon must be followed by a space:
      • {key: value}
    • In JSON hashes, you can butt the key and value right up to the colon:
      • {"key":"value"}
    • This seems minor until you witness how it conflicts with YAML’s timestamp format. (What is {10:20}?)
  2. C-style comments: /* */
    • Were removed from JSON.
  3. Single-quoted strings had different escaping rules between the two.
    • Such strings were removed from JSON.

The final answer is still being primed, but YAML’s definitely going to budge on this colon affair, folks! I’m sure you’ll be hearing once we’ve got it all ready for you.


Oh, and while scouting around in the JSON draft proposal, this little bit of regexp security caught my eye. Can’t hurt I guess.

 var my_JSON_object = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
     text.replace(/"(\\.|[^"\\])*"/g, ''))) &&
     eval('(' + text + ')');
said on 15 Apr 2006 at 19:52

Seems interesting. Perhaps someone could create a JSON -compatibility mode identifier for YAML documents.

said on 17 Apr 2006 at 10:52

will JSON be valid Ruby 2.0? The main obvious difference between json and ruby is the hash notation, which I believe is being addressed in Ruby 2.

What other differences are there ?

said on 18 Apr 2006 at 10:23

jakdak: so, RON ?

said on 01 May 2006 at 11:29

Ruby already supports the alternate , syntax for hashes, I don’t see why we shouldn’t get the : as well. It’d be nice to be able to swap structures between python, javascript, etc and ruby.

Also, I think json should enforce the :\s instead of yaml giving in. :\s just seems cleaner to me.

Comments are closed for this entry.