The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
JSON Closer to YAML, But No Cigar (Thanks Alot, Whitespace!)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
JSON Closer to YAML, But No Cigar (Thanks Alot, Whitespace!) Posted: Nov 14, 2005 5:39 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: JSON Closer to YAML, But No Cigar (Thanks Alot, Whitespace!)
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

A while ago, I had an epiphany about all JSON being valid YAML. Great news, right? You get two formats for one. This issue has undergone further scrutiny and, as usual, there is good news and bad news.

Douglas Crockford, the founder of JSON has removed /* .. */ comments from the JSON specification, which was identified as the singular incompatibility between JSON and YAML. In addition, single-quoted strings were removed which YAML handled differently (in terms of escaping.) So, this is good for unifying the two.

However, another minor difference has been found. In JSON structures, the colon and comma need not be spaced out between items in a collection. In YAML, they do. Observe:

 # valid JSON, also valid YAML
 {"nick": "Philarp Tremaine", "rank": "infantry", 
  "badge": "orange-striped, syrup-scented"}

 # valid JSON, not valid YAML
 {"nick":"Philarp Tremaine","rank":"infantry", 
  "badge":"orange-striped, syrup-scented"}

YAML requires the space after each colon or comma. This is because YAML supports commas and colons in plain, unquoted strings.

 # valid YAML, not valid JSON
 {nick: Philarp Tremain, walked: 1,000 miles,
  blog: http://courageousandwarstained.blogspot.com}

For now, if you’re using Syck to parse JSON, be sure the JSON outputter you’re using is YAML-safe JSON. Clark and Doug are working to find a middle-ground and the spotlight is on YAML’s buzzer finger right now. I’ll let ya know how it goes.

Read: JSON Closer to YAML, But No Cigar (Thanks Alot, Whitespace!)

Topic: Funky Graphics with QtRuby Previous Topic   Next Topic Topic: new_haven.rb first meeting / ruport bugs

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use