xref: /PHP-7.0/ext/json/tests/pass002.phpt (revision e5abc537)
1--TEST--
2JSON (http://www.crockford.com/JSON/JSON_checker/test/pass2.json)
3--SKIPIF--
4<?php if (!extension_loaded("json")) print "skip"; ?>
5--FILE--
6<?php
7
8$test = '[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]';
9echo 'Testing: ' . $test . "\n";
10echo "DECODE: AS OBJECT\n";
11$obj = json_decode($test);
12var_dump($obj);
13echo "DECODE: AS ARRAY\n";
14$arr = json_decode($test, true);
15var_dump($arr);
16
17echo "ENCODE: FROM OBJECT\n";
18$obj_enc = json_encode($obj);
19echo $obj_enc . "\n";
20echo "ENCODE: FROM ARRAY\n";
21$arr_enc = json_encode($arr);
22echo $arr_enc . "\n";
23
24echo "DECODE AGAIN: AS OBJECT\n";
25$obj = json_decode($obj_enc);
26var_dump($obj);
27echo "DECODE AGAIN: AS ARRAY\n";
28$arr = json_decode($arr_enc, true);
29var_dump($arr);
30
31?>
32--EXPECT--
33Testing: [[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
34DECODE: AS OBJECT
35array(1) {
36  [0]=>
37  array(1) {
38    [0]=>
39    array(1) {
40      [0]=>
41      array(1) {
42        [0]=>
43        array(1) {
44          [0]=>
45          array(1) {
46            [0]=>
47            array(1) {
48              [0]=>
49              array(1) {
50                [0]=>
51                array(1) {
52                  [0]=>
53                  array(1) {
54                    [0]=>
55                    array(1) {
56                      [0]=>
57                      array(1) {
58                        [0]=>
59                        array(1) {
60                          [0]=>
61                          array(1) {
62                            [0]=>
63                            array(1) {
64                              [0]=>
65                              array(1) {
66                                [0]=>
67                                array(1) {
68                                  [0]=>
69                                  array(1) {
70                                    [0]=>
71                                    array(1) {
72                                      [0]=>
73                                      string(12) "Not too deep"
74                                    }
75                                  }
76                                }
77                              }
78                            }
79                          }
80                        }
81                      }
82                    }
83                  }
84                }
85              }
86            }
87          }
88        }
89      }
90    }
91  }
92}
93DECODE: AS ARRAY
94array(1) {
95  [0]=>
96  array(1) {
97    [0]=>
98    array(1) {
99      [0]=>
100      array(1) {
101        [0]=>
102        array(1) {
103          [0]=>
104          array(1) {
105            [0]=>
106            array(1) {
107              [0]=>
108              array(1) {
109                [0]=>
110                array(1) {
111                  [0]=>
112                  array(1) {
113                    [0]=>
114                    array(1) {
115                      [0]=>
116                      array(1) {
117                        [0]=>
118                        array(1) {
119                          [0]=>
120                          array(1) {
121                            [0]=>
122                            array(1) {
123                              [0]=>
124                              array(1) {
125                                [0]=>
126                                array(1) {
127                                  [0]=>
128                                  array(1) {
129                                    [0]=>
130                                    array(1) {
131                                      [0]=>
132                                      string(12) "Not too deep"
133                                    }
134                                  }
135                                }
136                              }
137                            }
138                          }
139                        }
140                      }
141                    }
142                  }
143                }
144              }
145            }
146          }
147        }
148      }
149    }
150  }
151}
152ENCODE: FROM OBJECT
153[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
154ENCODE: FROM ARRAY
155[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
156DECODE AGAIN: AS OBJECT
157array(1) {
158  [0]=>
159  array(1) {
160    [0]=>
161    array(1) {
162      [0]=>
163      array(1) {
164        [0]=>
165        array(1) {
166          [0]=>
167          array(1) {
168            [0]=>
169            array(1) {
170              [0]=>
171              array(1) {
172                [0]=>
173                array(1) {
174                  [0]=>
175                  array(1) {
176                    [0]=>
177                    array(1) {
178                      [0]=>
179                      array(1) {
180                        [0]=>
181                        array(1) {
182                          [0]=>
183                          array(1) {
184                            [0]=>
185                            array(1) {
186                              [0]=>
187                              array(1) {
188                                [0]=>
189                                array(1) {
190                                  [0]=>
191                                  array(1) {
192                                    [0]=>
193                                    array(1) {
194                                      [0]=>
195                                      string(12) "Not too deep"
196                                    }
197                                  }
198                                }
199                              }
200                            }
201                          }
202                        }
203                      }
204                    }
205                  }
206                }
207              }
208            }
209          }
210        }
211      }
212    }
213  }
214}
215DECODE AGAIN: AS ARRAY
216array(1) {
217  [0]=>
218  array(1) {
219    [0]=>
220    array(1) {
221      [0]=>
222      array(1) {
223        [0]=>
224        array(1) {
225          [0]=>
226          array(1) {
227            [0]=>
228            array(1) {
229              [0]=>
230              array(1) {
231                [0]=>
232                array(1) {
233                  [0]=>
234                  array(1) {
235                    [0]=>
236                    array(1) {
237                      [0]=>
238                      array(1) {
239                        [0]=>
240                        array(1) {
241                          [0]=>
242                          array(1) {
243                            [0]=>
244                            array(1) {
245                              [0]=>
246                              array(1) {
247                                [0]=>
248                                array(1) {
249                                  [0]=>
250                                  array(1) {
251                                    [0]=>
252                                    array(1) {
253                                      [0]=>
254                                      string(12) "Not too deep"
255                                    }
256                                  }
257                                }
258                              }
259                            }
260                          }
261                        }
262                      }
263                    }
264                  }
265                }
266              }
267            }
268          }
269        }
270      }
271    }
272  }
273}
274