Answer the question
In order to leave comments, you need to log in
What causes an error when changing the value in json?
JSON:
"USD": {
"Value": 71.4783,
"Previous": 71.0863
},
$data = file_get_contents('values.json');
$data = json_decode($data , true);
$data['USD']['Value'] = "2";
$data = json_encode($data);
file_put_contents('values.json', $data);
Answer the question
In order to leave comments, you need to log in
I will now show you an absolutely secret piece of code, you will not find it anywhere else. This miracle solves 99% of the problems!
$data = file_get_contents('values.json');
$data = json_decode($data , true);
var_dump($data);
It looks like you have an extra comma in your JSON file. In the end.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question