A
A
Alexey Alyushenko2015-09-04 17:09:36
PHP
Alexey Alyushenko, 2015-09-04 17:09:36

How to get rid (execute) of js code in json in php?

Hello, how to get rid of js code inside json string?
There is json:

{"c":[{"v":new Date(2015,8,4),"f":"4 сент. 2015 г., 5:52 GMT-7"},{"v":0.0,"f":"0"}]}

As you can see, it has a new Date js function, because of this I can’t parse json_decode.
Actually, how can I remove this code, or how can I put it in quotes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Prozorov, 2015-09-04
@DjZooM

What you get is not really JSON. Form valid JSON and it will be parsed normally. You can pass the date value either as a string obtained with Date.toString(), or as a number of milliseconds using Date.getTime();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question