Tutorial by Examples

JSON (JavaScript Object Notation) is a lightweight data interchange format. Many web applications use it to send and receive data. In Ruby you can simply work with JSON. At first you have to require 'json', then you can parse a JSON string via the JSON.parse() command. require 'json' j = '{&q...
You can use JSON together with Ruby symbols. With the option symbolize_names for the parser, the keys in the resulting hash will be symbols instead of strings. json = '{ "a": 1, "b": 2 }' puts JSON.parse(json, symbolize_names: true) >> {:a=>1, :b=>2}

Page 1 of 1