The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
YAML is JSON

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.
YAML is JSON Posted: Apr 11, 2005 8:38 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: YAML is JSON
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

So, let’s presume you don’t use YAML because of its use of whitespace. You don’t like indentation describing data structures. For whatever reason: taste, upbringing, paranoia. Whatever. And we’ll presume you punch the sky as well. You don’t like the ether to have connotations.

Well, you can use YAML without whitespace. Using inline collections. Since the YAML 1.0 working draft, you can even use YAML inlines exclusively.

It looks just like JSON. In fact, I just realized that all JSON is valid YAML. Try it for yourself. (However, YAML doesn’t allow /* .. */ comments, so it does require some preprocessing.)

 require 'yaml'
 YAML::load %{
 {"menu": {
  "id": "file",
  "value": "File:",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}]}}}
 }

So, ethics question. Can I start to advertise Syck as a JSON parser now? That was the easiest feature I’ve ever added.

Read: YAML is JSON

Topic: Thoughts on Vooly Previous Topic   Next Topic Topic: Need to upgrade my typo install

Sponsored Links



Google
  Web Artima.com   

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