File: jsonp.phpt

package info (click to toggle)
php-json 1.3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 684 kB
  • ctags: 521
  • sloc: ansic: 3,878; xml: 446; php: 120; sh: 22; makefile: 16
file content (40 lines) | stat: -rw-r--r-- 636 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--TEST--
json_decode() with comments
--SKIPIF--
<?php
  if (!extension_loaded("json"))
    die('skip: json extension not available');
  if (!JSON_C_BUNDLED && version_compare(JSON_C_VERSION, "0.11", "le"))
    die('skip: need json-c library > 0.11')
?>
--FILE--
<?php

$jsons = array(
	"/* hello */\"foo\"",
	"// hello\n\"foo\"",
	"[\"\\n\"]",
	"  {\"one\":1}  ",
);
	
foreach ($jsons as $json) {
	echo "$json: ";
	var_dump(json_decode($json));
}

echo "Done\n";
?>
--EXPECTF--	
/* hello */"foo": NULL
// hello
"foo": NULL
["\n"]: array(1) {
  [0]=>
  string(1) "
"
}
  {"one":1}  : object(stdClass)#1 (1) {
  ["one"]=>
  int(1)
}
Done