Skip to content

How to compare JSON integer values #1708

Answered by steve-chavez
aspeakman asked this question in Q&A
Discussion options

You must be logged in to vote

Instead of the double arrowhead operator ->>(get as text) use the single arrowhead operator->(get as json). Like:

GET /example?json_field->b_int=lt.9

More info about pg json operators at: https://www.postgresql.org/docs/current/functions-json.html

Edit: Note that comparison operators will only work if the type is jsonb and not json

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@aspeakman
Comment options

@steve-chavez
Comment options

@aspeakman
Comment options

@aspeakman
Comment options

@steve-chavez
Comment options

Answer selected by wolfgangwalther
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1708 on December 27, 2020 00:48.