这是PHP中的一行json_encode函数
echo $_GET['callback'].'('.json_encode($jsona).')';
那个回报
jQuery183022578700515441597_1353992348618([{"label":["done","open","pending","draft","cancel"],"values":[{"label":"August","values":["175","32","1","0","0"]},{"label":"September","values":["450","130","1","0","1"]},{"label":"October","values":["150","396","1","5","0"]},{"label":"November","values":["0","0","0","3","0"]}]}])
我通过 JS (jQuery) 得到它们
$.ajax({
url: 'ajax/_state.php',
type: 'GET',
dataType: 'jsonp',
dataCharset: 'jsonp',
success: function (data) {
console.log(data);
}
});
但是返回的 JSON 中包含的所有数字都变成了字符串(不知道为什么?)。
例如,我如何将它们转换为整数;
{
'label': ['done', 'open', 'pending', 'draft', 'cancel'],
'values': [
{
'label': 'Sept',
'values': [20, 40, 15, 5,2]
},
{
'label': 'Oct',
'values': [30, 10, 45, 10]
},
{
'label': 'Nov',
'values': [38, 20, 35, 17]
}
]
}