Assuming I understood you correctly, you want to split the provided JSON object and write its subobjects to some tables.
PostgreSQL has several JSON operators that might help.
First of all, you should cast JSON's textual representation to type json. This allows you to use JSON operators and functions, such as -> (Get JSON object field):
select
'{
"ID":1,
"Name":"Pooja",
"School":[
{
"Name":"ABC",
"Address":"Nagpur"
},
{
"Name":"CDF"
},
{
"Name":"GHI",
"Year":{
"From":"2015",
"To":"2016"
}
}
]
}'::json -> 'Name';
?column?
----------
Pooja
(1 row)
Or, for example, #> (Get JSON object at specified path):
select 'YOUR_JSON'::json #> '{"School", 2, "Year"}';
?column?
----------------------------
{ +
"From":"2015",+
"To":"2016" +
}
(1 row)
All you have to do now is insert the result of the operator application into the table of your choice:
insert into user select 'YOUR_JSON'::json -> 'Name';
If you simply want to extract the School array, you could still use -> operator:
select 'YOUR_JSON'::json -> 'School';
?column?
-----------------------------
[ +
{ +
"Name":"ABC", +
"Address":"Nagpur"+
}, +
{ +
"Name":"CDF" +
}, +
{ +
"Name":"GHI", +
"Year":{ +
"From":"2015", +
"To":"2016" +
} +
} +
]
(1 row)
Read the documentation for more.