Structured data exchange: Ruby <=> Javascript
-
In Sketchup we have Ruby within it we have WebDialogs through which we have Javascript (through the Safari or IE Javascript VMs). I've always heard that if you need to exchange structured information like arrays, hashes, objects between Ruby and Javascript you should be emitting JSON strings back and forth. I run across this post by "why" entitled "YAML is JSON" and it got me thinking that maybe its YAML we should be working on.
There is a pure Javascript YAML emitter class ( probably you don't need a parser,... JSON is a proper Javascript subset and JSON.almost_equal?(YAML) == true
and a pure Ruby YAML class (emitter&parser) too!I haven't done any testing so someone with some more time,... please do the honours
I am pretty sure this isn't as easy I present it to be and I assume a 30% possibility of it working with minimal effort, although I think that we need to come up with a ruby library for Sketchup and deal with it once and for all.
Advertisement