Contents

Roo

JSON.generate()

Converts a Hash to a JSON Text object.

JSON.generate(what as Hash) as Text

Parameters

  • what: Hash object. The data to convert to JSON

Returns

  • JSON as a Text object

Example

var h = {"name" => "Bart", "age" => 10, "scores" => [50, 65, 30]}
JSON.generate(h) # {"age":10,"name":Bart,"scores":[50,65,30]}