README
1json 1.2.0
2==========
3
4This extension implements the JavaScript Object Notation (JSON)
5data-interchange format as specified in [0].
6
7Two functions are implemented: encoding and decoding. The decoding
8is handled by a parser based on JSON_checker[1] by Douglas Crockford.
9
10
11Function overview
12-----------------
13
14 string json_encode ( mixed value )
15
16json_encode returns a string containing the JSON representation of value.
17value can be any type except a resource.
18
19 mixed json_decode ( string json, [bool assoc] )
20
21json_decode takes a JSON string and converts it into a PHP variable.
22When assoc is given, and evaluates to TRUE, json_decode() will return
23any objects as associative arrays.
24
25
26Example usage
27-------------
28
29$arr = array("a"=>1,"b"=>2,"c"=>3,"d"=>4,"e"=>5);
30echo json_encode($arr);
31
32---> {"a":1,"b":2,"c":3,"d":4,"e":5}
33
34$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
35var_dump(json_decode($json));
36
37---> object(stdClass)#1 (5) {
38 ["a"]=>
39 int(1)
40 ["b"]=>
41 int(2)
42 ["c"]=>
43 int(3)
44 ["d"]=>
45 int(4)
46 ["e"]=>
47 int(5)
48 }
49
50$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
51var_dump(json_decode($json, true));
52
53---> array(5) {
54 ["a"]=>
55 int(1)
56 ["b"]=>
57 int(2)
58 ["c"]=>
59 int(3)
60 ["d"]=>
61 int(4)
62 ["e"]=>
63 int(5)
64 }
65
66
67Authors
68-------
69
70Omar Kilani <omar@php.net>
71
72
73---
74
75[0] http://www.crockford.com/JSON/draft-jsonorg-json-00.txt
76[1] http://www.crockford.com/JSON/JSON_checker/
77