php - Encoded json gets corrupted/escaped by PostgresQL? -
i using yii2 model hooked postgresql database. have behavior encodes , decodes attributes of model to/from json. encode/decode, using json helper, json::encode
, json::decode
methods.
the column in table of json type. example of ends in database:
"{\"additional_tags\":[\"#здрасте\",\"#кафе\"],\"vk\":\"vk.com\\\/privetik\"}"
when try decode php array, here's what's returned instead:
'{"additional_tags":["#здрасте","#кафе"],"vk":"vk.com\/privetik"}'
edit: come think of it, string seems fine, behavior of ::decode
method strange. essentially, remove escape slashes, instead of converting php array or throwing exception.
what should fix this? appreciate feedback.
looks string in database encoded twice. try passing through json::decode
time, bet return array.
Comments
Post a Comment