'How to turn string into json with php and whitespace and padding
I am struggling here. I have looked up many previous answers on this subject and nothing is working.
I have the following string and can't figure out how to get it to a php array. Any ideas?
[{ "Account": "XXXXXXXXXXX", "Transaction ID": 3830251003, "Timestamp": "05/06/2022 17:21:40", "Date": 2022-05-06, "Delta": "50,000.00", "Amount": "50,000.00", "Cash Change Type": " Fund Transaction", "Currency": "USD", },]
Solution 1:[1]
If you want to get it like a PHP array, store this response in a variable, like $json, and call the function json_decode, like this:
// Do your request...
// I expect your response is stored in a $json variable
$jsonToPhpArray = json_decode($json);
var_dump($jsonToPhpArray);
If, of course, your JSON array/object is correctly constructed, it works. You can try this. In the worst situation you will get a PHP error that can help you, like "Error parsing JSON, malformed JSON"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Harkhenon |
