Skip to content

Is there a way to filter by the content of JSON lists? #1862

Answered by wolfgangwalther
piterdias asked this question in Q&A
Discussion options

You must be logged in to vote

Two ideas here:

  • You could try to use arrow operators and @>, which is mapped to cs (contains). According to the PostgreSQL docs, you'd need to pass a json array, not an element here. So maybe something like this: GET /table_name?detalhe_objeto->Parametros Basicos->Estrategias=cs.["View 1"] - you'd probably need to percent-encode some of those characters. The space for sure and maybe also the [ ].
  • I'd just use a computed column, which returns the "Estrategias" as a proper postgres array - and then use something like this: GET /table_name?estrategias=cs.{View 1}. Much less quoting and escaping/percent-encoding needed here.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by wolfgangwalther
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #1861 on June 04, 2021 13:44.