I am using json_encode to display some data.
我使用json_encode来显示一些数据。
[{"name":"myname001","data":["[Date.UTC(1961, 1, 1),10]","[Date.UTC(1962, 1, 1),11]"},{"name":"myname002", "data":["[Date.UTC(1961, 1, 1),10]","[Date.UTC(1962, 1, 1),11]" ]]
How can I remove the double quotes from the values from my data?
如何从数据中的值中删除双引号?
[{"name":"myname001","data":[[Date.UTC(1961, 1, 1),10],[Date.UTC(1962, 1, 1),11]},{"name":"myname002", "data":[[Date.UTC(1961, 1, 1),10],[Date.UTC(1962, 1, 1),11] ]]
2 个解决方案
#1
Well, so easy.
好吧,这么容易。
The situation: I need to bring number to put together with highstock, and was not bringing anything.
情况:我需要将数字与highstock放在一起,并没有带来任何东西。
After I just did a new array with int numbers, this way is coming without double quotes.
在我刚刚使用int数字创建一个新数组后,这种方式没有双引号。
I don't know why people give negative without ask why the question.
我不知道为什么人们在没有问为什么问题的情况下给予否定。
Closed.
#2
Use the JSON_NUMERIC_CHECK option.
使用JSON_NUMERIC_CHECK选项。
<?php
$arr = array( 'row_id' => '1', 'name' => 'George' ); // fictional db result
echo json_encode( $arr, JSON_NUMERIC_CHECK ); // {"row_id":1,"name":"George"}
?>
#1
Well, so easy.
好吧,这么容易。
The situation: I need to bring number to put together with highstock, and was not bringing anything.
情况:我需要将数字与highstock放在一起,并没有带来任何东西。
After I just did a new array with int numbers, this way is coming without double quotes.
在我刚刚使用int数字创建一个新数组后,这种方式没有双引号。
I don't know why people give negative without ask why the question.
我不知道为什么人们在没有问为什么问题的情况下给予否定。
Closed.
#2
Use the JSON_NUMERIC_CHECK option.
使用JSON_NUMERIC_CHECK选项。
<?php
$arr = array( 'row_id' => '1', 'name' => 'George' ); // fictional db result
echo json_encode( $arr, JSON_NUMERIC_CHECK ); // {"row_id":1,"name":"George"}
?>