[英]Select UNIX_TIMESTAMP() returns strange JSON key
I am storing TIMESTAMPs in MySQL and returning them using a query similar to: 我将TIMESTAMP存储在MySQL中,并使用类似于以下查询的查询将它们返回:
SELECT UNIX_TIMESTAMP(field)...
It works, but upon returning them using json_encode my key: value
shows up as "UNIX_TIMESTAMP(orders.time)":"1357453256"
. 它可以工作,但是使用json_encode返回它们后,我的
key: value
显示为"UNIX_TIMESTAMP(orders.time)":"1357453256"
。 I'm not sure how to use this in Javascript. 我不确定如何在Javascript中使用它。
So my question is, how do I get JS to interpret this key:value pair? 所以我的问题是,如何让JS解释这个key:value对?
Give the results of UNIX_TIMESTAMP
an alias: 给
UNIX_TIMESTAMP
的结果UNIX_TIMESTAMP
一个别名:
SELECT UNIX_TIMESTAMP(field) AS field ...
Your resulting JSON should look like: 生成的JSON应该如下所示:
"field":"1357453256"
您始终可以使用方括号表示法:
var timestamp = json.foo.bar.["UNIX_TIMESTAMP(orders.time)"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.