作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试时间线图表: http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html#Data_Format数据以 JSON 提要的形式出现。
Google 想要这样的数据:
{
version:'0.6',
reqId:'0',
status:'ok',
sig:'4641982796834063168',
table:{
cols:[
{
id:'A',
label:'NEW A',
type:'string'
},
{
id:'B',
label:'B-label',
type:'number'
},
{
id:'C',
label:'C-label',
type:'datetime'
}
],
rows:[
{
c:[
{
v:'c'
},
{
v:3.0,
f:'3'
},
{
v:new Date(2008,
3,
30,
0,
31,
26 ),
f:'4/30/08 12:31 AM'
}
]
}
]
}
}
如何输出 Date 函数而不用像 'Date()' 这样的字符串定界符包裹它。
最佳答案
我只是将函数包装在 %% 个字符中,如下所示:
$something = array('%%new Date(...) %%','somevalue');
$json = json_encode($something);
并删除了这些 %% 字符和它们旁边的字符串分隔符。
$json = preg_replace("/(('|\")%%|%%(\"|'))/",'', $json);
关于php - 如何在 json 中输出 javascript 日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3146075/
我是一名优秀的程序员,十分优秀!