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?
3 Réponses
+ 1
It was not Json. PHP serialized object
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
- 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