Skip to content
Advertisement

INSERT STRING INTO JSON POSTGREE PHP

How to insert string value to json field in postgree? json value :

my_json_record = "{'brandCode':'TOY',
'brandName':'TOYOTA',
'VehicleCollateral':{'ownerName':'Lode',
                       'CertificateNumber':'x123245'}
}"

I try to do this thing

$my_json_var = json_decode($my_json_record);
insert into jsonx(json) value
(
$my_json_var;
)

and found this error. Query failed: ERROR: syntax error at or near “{“

can you help with my problem? Thx before..

Advertisement

Answer

JSON requires double quotes (“)

https://www.rfc-editor.org/rfc/rfc7159#section-13

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement