Answer the question
In order to leave comments, you need to log in
How to remove quotes in json file output using php?
Hello! For a sample, let's take a json file with the following content: { "name": "Вася", "age": "35"}
Let's say this file has been read and now before writing back, you need to remove quotes from Vasya and age
How can this be done?
$json = json_decode(file_get_contents('test.json'), true); //Читаю файл так
----------
file_put_contents('test.json', json_encode($json, JSON_UNESCAPED_UNICODE)); //Пишу файл так
Answer the question
In order to leave comments, you need to log in
you need to remove the quotes from Vasya
syntactically it is not correct
Vasya - string
35 - integer (it can be done without brackets intval(35))
Json cannot be without quotes, sorry. If you are going to use the built-in API of the language, then this will not work in any way. If you just save your pseudo-json - in a txt file or as a line in the database - cut whatever you want. I think removing the quote from the string will not be a problem for you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question