PostgreSQL
 sql >> Base de données >  >> RDS >> PostgreSQL

Interroger des éléments dans un tableau imbriqué d'un objet json dans postgresql 9.4 ou 9.5

-- assuming that jsontesting.data contains your JSON    
WITH info_data AS (
   SELECT enrolment_info->'info' AS info
   FROM jsontesting t, json_array_elements(t.data -> 'Data' -> 'enrolmentInfo') AS enrolment_info
)
SELECT info_item->>'courseID',
       info_item->>'school',
       info_item->>'enrollmentdate',
       info_item->>'finshdate',
       info_item->>'grade'
FROM info_data idata, json_array_elements(idata.info) AS info_item;