<?php
$int = 123;
echo json_encode($int)."<br />\n";
$str1 = "This is JSON";
echo json_encode($str1)."<br />\n";
$str2 = "νμ΄νΌν
";
echo json_encode($str2)."<br />\n";
$arr1 = array(1,2,3);
echo json_encode($arr1)."<br />\n";
$arr2 = array('numbers'=>$arr1, $str1, $str2);
echo json_encode($arr2)."<br />\n";
$obj = new stdClass();
$obj->a = $arr1;
echo json_encode($obj)."<br />\n";
?>
123
"This is JSON"
"\ud558\uc774\ud37c\ud14d"
[1,2,3]
{"numbers":[1,2,3],"0":"This is JSON","1":"\ud558\uc774\ud37c\ud14d"}
{"a":[1,2,3]}