YaySON #
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:
- 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}
?)
- In YAML hashes, the colon must be followed by a space:
- C-style comments:
/* */
- Were removed from JSON.
- 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 + ')');
FlashHater
Seems interesting. Perhaps someone could create a JSON -compatibility mode identifier for YAML documents.
jakdak
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 ?
MenTaLguY
jakdak: so, RON ?
Abica
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.