On the server side, I use PHP to write a json file in the format {}{}{}, file_put_contents is used to append the data to the client. js. It is also obtained through PHP in the format of {}{} (file_get_contents), rather than the standard json format [{},{}, {}] How can I get standard js... on the server side, I used PHP to write a json file in the format of {}{}{}. I used file_put_contents to write additional files.
The format {} (file_get_contents) obtained through PHP in client js is not the standard json format [{}, {}, {}]
How can I get the standard json format? When writing data in PHP (PHP only obtains {key/value}. How can this problem be solved ?), Or after js obtains the string, convert it to the standard format (how to do it ?)?
Ask a newbie, thanks.
Reply content:
On the server side, I used PHP to write a json file in the format of {}{}{}. I used file_put_contents to write additional files.
The format {} (file_get_contents) obtained through PHP in client js is not the standard json format [{}, {}, {}]
How can I get the standard json format? When writing data in PHP (PHP only obtains {key/value}. How can this problem be solved ?), Or after js obtains the string, convert it to the standard format (how to do it ?)?
Ask a newbie, thanks.
Put the content you want to write in$data = array();Medium,
Use
$data[] = $xxxxx;$data[] = $yyyyy;//....file_put_contents('xx.js', json_encode($data));
ThenjsYou can load thisxx.jsNow.
It is recommended that the backend server write files in the standard JSON format, and the front-end can directly parse the files.