2 # = JavaScript Object Notation (JSON)
4 # JSON is a lightweight data-interchange format. It is easy for us
5 # humans to read and write. Plus, equally simple for machines to generate or parse.
6 # JSON is completely language agnostic, making it the ideal interchange format.
8 # Built on two universally available structures:
9 # 1. A collection of name/value pairs. Often referred to as an _object_, hash table, record, struct, keyed list, or associative array.
10 # 2. An ordered list of values. More commonly called an _array_, vector, sequence or list.
12 # To read more about JSON visit: http://json.org
16 # To parse a JSON string received by another application or generated within
17 # your existing application:
21 # my_hash = JSON.parse('{"hello": "goodbye"}')
22 # puts my_hash["hello"] => "goodbye"
24 # Notice the extra quotes <tt>''</tt> around the hash notation. Ruby expects
25 # the argument to be a string and can't convert objects like a hash or array.
27 # Ruby converts your string into a hash
31 # Creating a JSON string for communication or serialization is
36 # my_hash = {:hello => "goodbye"}
37 # puts JSON.generate(my_hash) => "{\"hello\":\"goodbye\"}"
39 # Or an alternative way:
42 # puts {:hello => "goodbye"}.to_json => "{\"hello\":\"goodbye\"}"
44 # <tt>JSON.generate</tt> only allows objects or arrays to be converted
45 # to JSON syntax. <tt>to_json</tt>, however, accepts many Ruby classes
46 # even though it acts only as a method for serialization:
55 require 'json/version'