Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / api / Ext.JSON.html
1 <!DOCTYPE html><html><head><title>Ext.JSON | Ext JS 4.0 Documentation</title><script type="text/javascript" src="../ext-all.js"></script><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../scrollbars.css" type="text/css"><link rel="stylesheet" href="../docs.css" type="text/css"><link id="styleCss" rel="stylesheet" href="../style.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script><link rel="stylesheet" href="../prettify.css" type="text/css"><!-- link(rel: 'stylesheet', href: req.baseURL + '/css/ext4.css', type: 'text/css')--><link rel="shortcut icon" type="image/ico" href="../favicon.ico"><!--[if IE]>
2 <style type="text/css">.head-band { display: none; }
3 .header { border: 0; top: 0; left: 0px; background: url(../header.gif) repeat-x; }
4 .doc-tab .members .member a.more { background-color: #efefef; }
5 </style><link rel="stylesheet" href="/new/css/ie.css" type="text/css"><![endif]-->
6 </head><body id="ext-body" class="iScroll"><div id="notice" class="notice">For up to date documentation and features, visit 
7 <a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a></div><div class="wrapper"><div class="head-band"></div><div class="header"><h2><a href="../index.html">Sencha Documentation</a></h2></div><div id="search"><form><input type="text" placeholder="Search" id="search-field" autocomplete="off" name="q"></form><div id="search-box"></div></div><div id="treePanel"></div><div id="container"><script type="text/javascript">
8
9     req = {
10         liveURL: '.',
11         standAloneMode: true,
12         origDocClass: 'Ext.JSON',
13         docClass: 'Ext.JSON',
14         docReq: 'Ext.JSON',
15         version: '4.0',
16         baseURL: '.',
17         baseDocURL: '.',
18         baseProdURL: '.'
19     };
20
21     clsInfo = {};
22
23
24
25 </script>
26
27 <script type="text/javascript" src="../search.js"></script>
28 <!--script type="text/javascript" src="/new/javascripts/app/examples.js"></script-->
29 <script type="text/javascript" src="../class_tree.js"></script>
30 <script type="text/javascript" src="../class_doc.js"></script>
31 <script type="text/javascript">
32     req.source = 'JSON3.html#Ext-JSON';
33     clsInfo = {"methods":["decode","encode","encodeDate"],"cfgs":[],"properties":[],"events":[],"subclasses":[]};
34     Ext.onReady(function() {
35         Ext.create('Docs.classPanel');
36     });
37 </script><div id="top-block" class="top-block"><h1 id="clsTitle" class="cls"><a href="../source/JSON3.html#Ext-JSON" target="_blank">Ext.JSON</a></h1></div><div id="docContent"><div id="doc-overview-content"><div class="lft"><p>Modified version of Douglas Crockford"s json.js that doesn"t
38 mess with the Object prototype
39 http://www.json.org/js.html</p>
40 <div class="members"><div class="m-methods"><a name="methods"></a><div class="definedBy">Defined By</div><h3 class="mth p">Methods</h3><div id="method-decode" class="member f ni"><a href="Ext.JSON.html#method-decode" rel="method-decode" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.JSON.html" class="definedIn docClass">Ext.JSON</a><br/><a href="../source/JSON3.html#Ext-JSON-method-decode" class="viewSource">view source</a></div><a name="decode"></a><a name="method-decode"></a><a href="Ext.JSON.html#" rel="method-decode" class="cls expand">decode</a>(
41 <span class="pre">String json, [Boolean safe]</span>)
42  : Object</div><div class="description"><div class="short">Decodes (parses) a JSON string to an object. If the JSON is invalid, this function throws a SyntaxError unless the sa...</div><div class="long"><p>Decodes (parses) a JSON string to an object. If the JSON is invalid, this function throws a SyntaxError unless the safe option is set.</p>
43 <h3 class="pa">Parameters</h3><ul><li><span class="pre">json</span> : String<div class="sub-desc"><p>The JSON string</p>
44 </div></li><li><span class="pre">safe</span> : Boolean<div class="sub-desc"><p>(optional) Whether to return null or throw an exception if the JSON is invalid.</p>
45 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Object</span>&nbsp; &nbsp;<p>The resulting object</p>
46 </li></ul></div></div></div><div id="method-encode" class="member ni"><a href="Ext.JSON.html#method-encode" rel="method-encode" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.JSON.html" class="definedIn docClass">Ext.JSON</a><br/><a href="../source/JSON3.html#Ext-JSON-method-encode" class="viewSource">view source</a></div><a name="encode"></a><a name="method-encode"></a><a href="Ext.JSON.html#" rel="method-encode" class="cls expand">encode</a>(
47 <span class="pre">Mixed o</span>)
48  : String</div><div class="description"><div class="short"><p>Encodes an Object, Array or other value</p>
49 </div><div class="long"><p>Encodes an Object, Array or other value</p>
50 <h3 class="pa">Parameters</h3><ul><li><span class="pre">o</span> : Mixed<div class="sub-desc"><p>The variable to encode</p>
51 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span>&nbsp; &nbsp;<p>The JSON string</p>
52 </li></ul></div></div></div><div id="method-encodeDate" class="member ni"><a href="Ext.JSON.html#method-encodeDate" rel="method-encodeDate" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.JSON.html" class="definedIn docClass">Ext.JSON</a><br/><a href="../source/JSON3.html#Ext-JSON-method-encodeDate" class="viewSource">view source</a></div><a name="encodeDate"></a><a name="method-encodeDate"></a><a href="Ext.JSON.html#" rel="method-encodeDate" class="cls expand">encodeDate</a>(
53 <span class="pre">Date d</span>)
54  : String</div><div class="description"><div class="short">Encodes a Date. This returns the actual string which is inserted into the JSON string as the literal expression.
55 The ...</div><div class="long"><p>Encodes a Date. This returns the actual string which is inserted into the JSON string as the literal expression.
56 <b>The returned value includes enclosing double quotation marks.</b></p>
57
58
59 <p>The default return format is "yyyy-mm-ddThh:mm:ss".</p>
60
61
62 <p>To override this:</p>
63
64
65 <pre><code>     Ext.JSON.encodeDate = function(d) {
66      return d.format('"Y-m-d"');
67      };
68      </code></pre>
69
70 <h3 class="pa">Parameters</h3><ul><li><span class="pre">d</span> : Date<div class="sub-desc"><p>The Date to encode</p>
71 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">String</span>&nbsp; &nbsp;<p>The string literal to use in a JSON string.</p>
72 </li></ul></div></div></div></div></div></div></div><div id="pageContent"></div></div></div></div></body></html>