Top_bar_btn_squeeze
Friday, Nov 17 2006 no comments
First there was the great news JSON being subset of YAML. Great as it allows you to use Ruby's YAML(Syck) parser to load JSON fragments, first step to Javascript-Ruby cross processing nirvana. Then sadly it turns out that whitespace ruins the party unless using a YAML safe outputter. Good news is that you can still munge JSON into YAML with a simple translation:
YAML.load(unsafe_json.gsub(/,"(\w+)"/, ', "\1"').gsub(/"(\w+)":/, '"\1": '))

Technorati tags: , , ,

Comments