diff options
author | Florian Frank <flori@ping.de> | 2011-06-20 14:53:03 +0200 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2011-06-20 14:53:03 +0200 |
commit | 40dee6ceb5c6547f67b520d237b645a8f97bf937 (patch) | |
tree | 11ee11273c9488e102c3b0841404a5acde53c65b /doc/files/lib/json_rb.html | |
parent | fda7896e7611f01d40e66072ce79ed0d97f6c08f (diff) | |
download | json-40dee6ceb5c6547f67b520d237b645a8f97bf937.tar.gz |
generated documentation
Diffstat (limited to 'doc/files/lib/json_rb.html')
-rw-r--r-- | doc/files/lib/json_rb.html | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/doc/files/lib/json_rb.html b/doc/files/lib/json_rb.html new file mode 100644 index 0000000..ce20837 --- /dev/null +++ b/doc/files/lib/json_rb.html @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>json.rb</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" /> + <link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" /> + <script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script> + <script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script> + <script src="../../js/main.js" type="text/javascript" charset="utf-8"></script> +</head> + +<body> + <div class="banner"> + <h1> + json.rb + </h1> + <ul class="files"> + <li>lib/json.rb</li> + <li>Last modified: 2011-06-20 14:53:00 +0200</li> + </ul> + </div> + + <div id="bodyContent"> + <div id="content"> + + <div class="description"> + <h1>JavaScript <a href="../../classes/Object.html">Object</a> Notation (<a href="../../classes/JSON.html">JSON</a>)</h1> +<p> +<a href="../../classes/JSON.html">JSON</a> is a lightweight +data-interchange format. It is easy for us humans to read and write. Plus, +equally simple for machines to generate or parse. <a +href="../../classes/JSON.html">JSON</a> is completely language agnostic, +making it the ideal interchange format. +</p> +<p> +Built on two universally available structures: +</p> +<pre> + 1. A collection of name/value pairs. Often referred to as an _object_, hash table, record, struct, keyed list, or associative array. + 2. An orderd list of values. More commonly named as an _array_, vector, sequence, or list. +</pre> +<p> +To read more about <a href="../../classes/JSON.html">JSON</a> visit: <a +href="http://json.org">json.org</a> +</p> +<h2>Parsing <a href="../../classes/JSON.html">JSON</a></h2> +<p> +To parse a <a href="../../classes/JSON.html">JSON</a> string received by +another application, or generated within your existing application: +</p> +<pre> + require 'json' + + my_hash = JSON.parse('{"hello": "goodbye"}') + puts my_hash["hello"] => "goodbye" +</pre> +<p> +Notice the extra quotes <tt>''</tt> around the hash notation. Ruby expects +the argument to be a string and can’t convert objects like a hash or +array. +</p> +<p> +Ruby converts your string into a hash +</p> +<h2>Generating <a href="../../classes/JSON.html">JSON</a></h2> +<p> +Creating a <a href="../../classes/JSON.html">JSON</a> string for +communication or serialization is just as simple. +</p> +<pre> + require 'json' + + my_hash = {:hello => "goodbye"} + puts JSON.generate(my_hash) => "{\"hello\":\"goodbye\"}" +</pre> +<p> +Or an alternative way: +</p> +<pre> + require 'json' + puts {:hello => "goodbye"}.to_json => "{\"hello\":\"goodbye\"}" +</pre> +<p> +<tt><a href="../../classes/JSON.html#M000063">JSON.generate</a></tt> only +allows objects or arrays to be converted to <a +href="../../classes/JSON.html">JSON</a> syntax. While <tt>to_json</tt> +accepts many Ruby classes even though it only acts a method for +serialization: +</p> +<pre> + require 'json' + + 1.to_json => "1" +</pre> + + </div> + + + + <div class="sectiontitle">Required Files</div> + <ul> + + <li>json/version</li> + + <li>json/ext</li> + + <li>json/pure</li> + + </ul> + + + + + + + + + + + + + + <div class="sectiontitle">Classes and Modules</div> + <ul> + + <li><span class="type">MODULE</span> <a href="../../classes/JSON.html">JSON</a></li> + + <li><span class="type">CLASS</span> <a href="../../classes/Object.html">Object</a></li> + + </ul> + + + + + + + +</div> + </div> + </body> +</html>
\ No newline at end of file |