0

What format this text is? JSON?

a:1:{i:0;a:4:{s:3:\"aid\";s:9:\"Anonymous\";s:5:\"email\";s:0:\"\";s:4:\"time\";i:1586706373;s:7:\"message\";s:6:\"fdsdsf\";}} I was working with php mysql and I found this value in tables. What is it called?

15th Jun 2020, 12:08 AM
Parsa Gholipout
Parsa Gholipout - avatar
3 Answers
+ 1
It was not Json. PHP serialized object
4th Jul 2020, 8:20 AM
Parsa Gholipout
Parsa Gholipout - avatar
0
If it's json then why can't I parse it with Javascript method. I removed unscaping characters. JSON.parse('a:1:{i:0;a:4:{s:3:"aid";s:9:"Anonymous";s:5:"email";s:0:"";s:4:"time";i:1586706373;s:7:"message";s:6:"fdsdsf";}}'); results: Uncaught SyntaxError: Unexpected token a in JSON at position 0
16th Jun 2020, 4:38 PM
Parsa Gholipout
Parsa Gholipout - avatar
- 1
Seriously, it is JSON. The double quotes is escaped. But minimize the usage of json in database. Store them in different columns. For example if you want to get the rows for which the message contains a certain keyword, it will always consider all the Json content, which is not what you want in most cases
15th Jun 2020, 4:16 PM
Lingesan S
Lingesan S - avatar