Discussion:
Query on JSON field type
(too old to reply)
Mick
2012-11-14 22:27:38 UTC
Permalink
Hello,
my field is called Samples and the value is {"R":100, "S":101, "Q":102}. how do I find all Samples for which "R" = 100?
Thank you in advance.
Merlin Moncure
2012-11-15 17:00:27 UTC
Permalink
Post by Mick
Hello,
my field is called Samples and the value is {"R":100, "S":101, "Q":102}. how do I find all Samples for which "R" = 100?
Thank you in advance.
for xml type we have xpath function for these type of queries.
unfortunately, no analog for json type exists as of yet. so, here our
our options:

*) pull to client side and filter there
*) search textually (say, by regular expression) and hope for the best
*) implement backend function in a language that speaks json, or can
be extended to do so. pl/v8 and p/python are both noteworthy, but
almost all languages have json features of some kind. your function
will do simple test and return bool for example.

merlin
--
Sent via pgsql-novice mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
Mick
2012-11-15 20:11:56 UTC
Permalink
Thank you very much for your reply, Merlin :)
Post by Merlin Moncure
Post by Mick
Hello,
my field is called Samples and the value is {"R":100, "S":101, "Q":102}. how do I find all Samples for which "R" = 100?
Thank you in advance.
for xml type we have xpath function for these type of queries.
unfortunately, no analog for json type exists as of yet. so, here our
*) pull to client side and filter there
*) search textually (say, by regular expression) and hope for the best
*) implement backend function in a language that speaks json, or can
be extended to do so. pl/v8 and p/python are both noteworthy, but
almost all languages have json features of some kind. your function
will do simple test and return bool for example.
merlin
--
Sent via pgsql-novice mailing list
http://www.postgresql.org/mailpref/pgsql-novice
Loading...