Skip to content Skip to sidebar Skip to footer

Parsing Ruby Hash Literal Using Javascript

I need to take raw client text in a web form and send it back to a Tomcat servlet as JSON. For legacy reasons, this input may be formatted as a Ruby hash. I also cannot force my cl

Solution 1:

JSON is a Ruby standard library. You've to just require it:

require 'json'

data = {:hello =>"goodbye"}
p data.to_json #=>"{\"hello\":\"goodbye\"}"

Ref: Generating JSON

Post a Comment for "Parsing Ruby Hash Literal Using Javascript"