Postgres has this JSON datatype and I am wondering how can I query data inside a JSON array ? I am using Postgres 9.3.1
I have inserted into PUBLISHER table that has these 2 fields name: string and data: json
INSERT INTO PUBLISHER (name, data) VALUES ('PUB1', [{"code":"PA1","author":"James","type":"Novel"},{"code":"PA2","author":"John","type":"Science"}]
INSERT INTO PUBLISHER (name, data) VALUES ('PUB2', [{"code":"PA1","author":"Dickens","type":"Novel"},{"code":"PA2","author":"Tom","type":"Comic"}]
I want to do a query and list out authors with the type "Novel". In this case it would be "James" and "Tom" that should be the output.
Something of this sort of query:
select name, authorfromdata from publisher where data->type is "Novel"