0

I am using json_encode to display some 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]" ]]

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] ]]
4
  • 1
    Removing quotes from values would make your JSON invalid. Commented May 11, 2015 at 20:13
  • Yes, but I need to remove it. Some idea? Commented May 11, 2015 at 20:17
  • I want to see why the HighStock need to read the JSON without the double quotes. Because this I need a way to remove it. Commented May 11, 2015 at 20:18
  • @JayBlanchard Yes, I know. But after my json_encode the HighStock won't work with double quotes, I need to check why, because this my question. Commented May 11, 2015 at 20:20

2 Answers 2

1

Well, so easy.

The situation: I need to bring number to put together with highstock, and was not bringing anything.

After I just did a new array with int numbers, this way is coming without double quotes.

I don't know why people give negative without ask why the question.

Closed.

Sign up to request clarification or add additional context in comments.

Comments

0

Use the JSON_NUMERIC_CHECK option.

<?php
$arr = array( 'row_id' => '1', 'name' => 'George' ); // fictional db result
echo json_encode( $arr, JSON_NUMERIC_CHECK ); // {"row_id":1,"name":"George"}
?>

1 Comment

seems JSON_NUMERIC_CHECK also change a year that is between double qoutes, e.g. "2016".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.