What I have done till now is :
DO
$do$
DECLARE
namz Text;
jsonObject json =
'{
"Name": "Kshitiz Kala",
"Education": "B.Tech",
"Skills": ["J2EE", "JDBC", "Html"]
}';
BEGIN
SELECT jsonObject->'Name' into namz;
select namz;
END
$do$
I am not finding any success here.
actual problem is I am passing a json Object to a stored procedure which will store the data in three different table 1) user table contains user_id, user_name, user_edu. 2) skill table contain skill_id, skill_name. 3) user_skill table contain id, user_id, usr_skill_id.
This is the json object I am passing from Django application
{"Name": "Kshitiz Kala", "Education": "B.Tech", "Skills": ["J2EE", "JDBC", "Html"]}
Your json code is fine, just check:
SELECT '{"Name": "Kshitiz Kala",
"Education": "B.Tech",
"Skills": ["J2EE", "JDBC", "Html"]
}'::json->'Name'
or in pgplsql:
DO
$do$
DECLARE
namz Text;
jsonObject json =
'{
"Name": "Kshitiz Kala",
"Education": "B.Tech",
"Skills": ["J2EE", "JDBC", "Html"]
}';
BEGIN
SELECT jsonObject->'Name' into namz;
raise 'JSON value Name is %', namz;
END
$do$
Problem is somewhere else. Eg. last line in this block won't do anything (SELECT namz in plpgpsql)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.