source: branches/feature-module-update/data/module/Services/JSON/doc/Services_JSON/Services_JSON.html @ 16259

Revision 16259, 10.6 KB checked in by adachi, 14 years ago (diff)

Services_JSONを追加

  • Property svn:mime-type set to text/plain
Line 
1<?xml version="1.0" encoding="iso-8859-1"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3  <html xmlns="http://www.w3.org/1999/xhtml">
4        <head>
5            <!-- template designed by Marco Von Ballmoos -->
6            <title>Docs For Class Services_JSON</title>
7            <link rel="stylesheet" href="../media/stylesheet.css" />
8            <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
9        </head>
10        <body>
11            <div class="page-body">         
12<h2 class="class-name">Class Services_JSON</h2>
13
14<a name="sec-description"></a>
15<div class="info-box">
16    <div class="info-box-title">Description</div>
17    <div class="nav-bar">
18                    <span class="disabled">Description</span> |
19                                                            <a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
20                       
21            </div>
22    <div class="info-box-body">
23        <!-- ========== Info from phpDoc block ========= -->
24<p class="short-description">Converts to and from JSON format.</p>
25<p class="description"><p>Brief example of use:</p><p><pre><code><pre><br />1 <span class="src-comm">// create a new instance of Services_JSON</span><br />2 <span class="src-var">$json</span> = <span class="src-key">new</span> <a href="../Services_JSON/Services_JSON.html#methodServices_JSON">Services_JSON</a><span class="src-sym">(</span><span class="src-sym">)</span>;<br />3     <br />4      <span class="src-comm">// convert a complexe value to JSON notation, and send it to the browser</span><br />5      <span class="src-var">$value</span> = <span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">'foo'</span><span class="src-sym">,</span> <span class="src-str">'bar'</span><span class="src-sym">,</span> <span class="src-key">array</span><span class="src-sym">(</span><span class="src-num">1</span><span class="src-sym">,</span> <span class="src-num">2</span><span class="src-sym">,</span> <span class="src-str">'baz'</span><span class="src-sym">)</span><span class="src-sym">,</span> <span class="src-key">array</span><span class="src-sym">(</span><span class="src-num">3</span><span class="src-sym">,</span> <span class="src-key">array</span><span class="src-sym">(</span><span class="src-num">4</span><span class="src-sym">)</span><span class="src-sym">)</span><span class="src-sym">)</span>;<br />6      <span class="src-var">$output</span> = <span class="src-var">$json</span><span class="src-sym">-&gt;</span><a href="../Services_JSON/Services_JSON.html#methodencode">encode</a><span class="src-sym">(</span><span class="src-var">$value</span><span class="src-sym">)</span>;<br />7     <br />8      print<span class="src-sym">(</span><span class="src-var">$output</span><span class="src-sym">)</span>;<br />9      <span class="src-comm">// prints: [&quot;foo&quot;,&quot;bar&quot;,[1,2,&quot;baz&quot;],[3,[4]]]</span><br />10    <br />11     <span class="src-comm">// accept incoming POST data, assumed to be in JSON notation</span><br />12     <span class="src-var">$input</span> = <a href="http://www.php.net/file_get_contents">file_get_contents</a><span class="src-sym">(</span><span class="src-str">'php://input'</span><span class="src-sym">,</span> <span class="src-num">1000000</span><span class="src-sym">)</span>;<br />13     <span class="src-var">$value</span> = <span class="src-var">$json</span><span class="src-sym">-&gt;</span><a href="../Services_JSON/Services_JSON.html#methoddecode">decode</a><span class="src-sym">(</span><span class="src-var">$input</span><span class="src-sym">)</span>;</pre></code></pre></p></p>
26        <p class="notes">
27            Located in <a class="field" href="_JSON_php.html">/JSON.php</a> (line <span class="field">115</span>)
28        </p>
29       
30               
31        <pre></pre>
32   
33            </div>
34</div>
35
36
37
38    <a name="sec-method-summary"></a>
39    <div class="info-box">
40        <div class="info-box-title">Method Summary</span></div>
41        <div class="nav-bar">
42            <a href="#sec-description">Description</a> |
43                                    <span class="disabled">Methods</span> (<a href="#sec-methods">details</a>)
44        </div>
45        <div class="info-box-body">         
46            <div class="method-summary">
47                               
48                <div class="method-definition">
49                                            <span class="method-result">Services_JSON</span>
50                                        <a href="#Services_JSON" title="details" class="method-name">Services_JSON</a>
51                                            (<span class="var-type">int</span>&nbsp;<span class="var-name">$use</span>)
52                                    </div>
53                               
54                <div class="method-definition">
55                                            <span class="method-result">mixed</span>
56                                        <a href="#decode" title="details" class="method-name">decode</a>
57                                            (<span class="var-type">string</span>&nbsp;<span class="var-name">$str</span>)
58                                    </div>
59                               
60                <div class="method-definition">
61                                            <span class="method-result">mixed</span>
62                                        <a href="#encode" title="details" class="method-name">encode</a>
63                                            (<span class="var-type">mixed</span>&nbsp;<span class="var-name">$var</span>)
64                                    </div>
65                               
66                <div class="method-definition">
67                                            <span class="method-result">void</span>
68                                        <a href="#isError" title="details" class="method-name">isError</a>
69                                            (<span class="var-type">mixed</span>&nbsp;<span class="var-name">$data</span>, [<span class="var-type">mixed</span>&nbsp;<span class="var-name">$code</span> = <span class="var-default">null</span>])
70                                    </div>
71                            </div>
72        </div>
73    </div>     
74
75   
76    <a name="sec-methods"></a>
77    <div class="info-box">
78        <div class="info-box-title">Methods</div>
79        <div class="nav-bar">
80            <a href="#sec-description">Description</a> |
81                                                    <a href="#sec-method-summary">Methods</a> (<span class="disabled">details</span>)
82                       
83        </div>
84        <div class="info-box-body">
85            <A NAME='method_detail'></A>
86<a name="methodServices_JSON" id="Services_JSON"><!-- --></a>
87<div class="evenrow">
88   
89    <div class="method-header">
90        <span class="method-title">Constructor Services_JSON</span> (line <span class="line-number">133</span>)
91    </div>
92   
93    <!-- ========== Info from phpDoc block ========= -->
94<p class="short-description">constructs a new JSON instance</p>
95   
96    <div class="method-signature">
97        <span class="method-result">Services_JSON</span>
98        <span class="method-name">
99            Services_JSON
100        </span>
101                    (<span class="var-type">int</span>&nbsp;<span class="var-name">$use</span>)
102            </div>
103   
104            <ul class="parameters">
105                    <li>
106                <span class="var-type">int</span>
107                <span class="var-name">$use</span><span class="var-description">: <p>object behavior flags; combine with boolean-OR</p><p>possible values: <ul><li>SERVICES_JSON_LOOSE_TYPE:  loose typing.
108                                   &quot;{...}&quot; syntax creates associative arrays
109                                   instead of objects in decode().</li><li>SERVICES_JSON_SUPPRESS_ERRORS:  error suppression.
110                                   Values which can't be encoded (e.g. resources)
111                                   appear as NULL instead of throwing errors.
112                                   By default, a deeply-nested resource will
113                                   bubble up with an error, so all return values
114                                   from encode() should be checked with isError()</li></ul></p></span>          </li>
115                </ul>
116       
117       
118    </div>
119<a name="methoddecode" id="decode"><!-- --></a>
120<div class="oddrow">
121   
122    <div class="method-header">
123        <span class="method-title">decode</span> (line <span class="line-number">484</span>)
124    </div>
125   
126    <!-- ========== Info from phpDoc block ========= -->
127<p class="short-description">decodes a JSON string into appropriate variable</p>
128    <ul class="tags">
129                <li><span class="field">return:</span> number, boolean, string, array, or object                    corresponding to given JSON input string.                    See argument 1 to Services_JSON() above for object-output behavior.                    Note that decode() always returns strings                    in ASCII or UTF-8 format!</li>
130                <li><span class="field">access:</span> public</li>
131            </ul>
132   
133    <div class="method-signature">
134        <span class="method-result">mixed</span>
135        <span class="method-name">
136            decode
137        </span>
138                    (<span class="var-type">string</span>&nbsp;<span class="var-name">$str</span>)
139            </div>
140   
141            <ul class="parameters">
142                    <li>
143                <span class="var-type">string</span>
144                <span class="var-name">$str</span><span class="var-description">: JSON-formatted string</span>          </li>
145                </ul>
146       
147       
148    </div>
149<a name="methodencode" id="encode"><!-- --></a>
150<div class="evenrow">
151   
152    <div class="method-header">
153        <span class="method-title">encode</span> (line <span class="line-number">237</span>)
154    </div>
155   
156    <!-- ========== Info from phpDoc block ========= -->
157<p class="short-description">encodes an arbitrary variable into JSON format</p>
158    <ul class="tags">
159                <li><span class="field">return:</span> JSON string representation of input var or an error if a problem occurs</li>
160                <li><span class="field">access:</span> public</li>
161            </ul>
162   
163    <div class="method-signature">
164        <span class="method-result">mixed</span>
165        <span class="method-name">
166            encode
167        </span>
168                    (<span class="var-type">mixed</span>&nbsp;<span class="var-name">$var</span>)
169            </div>
170   
171            <ul class="parameters">
172                    <li>
173                <span class="var-type">mixed</span>
174                <span class="var-name">$var</span><span class="var-description">: any number, boolean, string, array, or object to be encoded.                            see argument 1 to Services_JSON() above for array-parsing behavior.                            if var is a strng, note that encode() always expects it                            to be in ASCII or UTF-8 format!</span>          </li>
175                </ul>
176       
177       
178    </div>
179<a name="methodisError" id="isError"><!-- --></a>
180<div class="oddrow">
181   
182    <div class="method-header">
183        <span class="method-title">isError</span> (line <span class="line-number">766</span>)
184    </div>
185   
186    <!-- ========== Info from phpDoc block ========= -->
187    <ul class="tags">
188                <li><span class="field">todo:</span> Ultimately, this should just call PEAR::isError()</li>
189            </ul>
190   
191    <div class="method-signature">
192        <span class="method-result">void</span>
193        <span class="method-name">
194            isError
195        </span>
196                    (<span class="var-type">mixed</span>&nbsp;<span class="var-name">$data</span>, [<span class="var-type">mixed</span>&nbsp;<span class="var-name">$code</span> = <span class="var-default">null</span>])
197            </div>
198   
199       
200       
201    </div>
202                       
203        </div>
204    </div>
205   
206    <p class="notes" id="credit">
207        Documentation generated on Tue, 27 Jun 2006 22:54:25 -0700 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.2.3</a>
208    </p>
209    </div></body>
210</html>
Note: See TracBrowser for help on using the repository browser.