-1

I am a newbie in php so I don't know if this is complicated or easy. I have string like below (this is not json)

{"time":"2022-05-14T07:10:53+00:00","host":"xxxxxxxxxxxxxxxx","forwarded_host":"xxxx","remote_addr":"xxxxxxx","req_method":"OPTIONS","req_length":855,"req_uri":"xxxxx","https":"xxx","uri":"/index.php","query_str":"","status":"204","bytes_sent":464,"body_bytes_sent":0,"referer":"xxxxxxx","ua":"xxxxxxx","forwarded_for":"xxxxxx","forwarded_proto":"https","req_time":0.014,"up_res_time":"0.015"}

Has anyway to convert it to object like this ?

{
   "time": "2022-05-14T07:10:53+00:00",
   "host": "XXXXXXXXXXXXX",
   ...
}

Thank you for your reading

thuc.ta
  • 1
  • 3
  • [json_decode()](https://www.php.net/manual/function.json-decode.php) – Phil May 15 '22 at 03:53
  • 1
    _"this is not json"_... https://jsonlint.com/ disagrees – Phil May 15 '22 at 03:59
  • 1
    It's definitely JSON. But what are you actually asking? Your desired result seems to be simply a cosmetic visual change to the layout of the same data. JSON is not a presentation format, and there's no "conversion" happening in what you're proposing. – ADyson May 15 '22 at 07:51

0 Answers0