Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 6219

JavaScript Object Notation (JSON) is an open, human and machine-readable standard that facilitates data interchange, and along with XML is the main format for data interchange used on the modern web.

10 votes

Order specific columns in json_agg

Without knowing exactly what you meant by 'The "distinct" does work the "order by" does not.', I guess you get an error: ERROR: in an aggregate with DISTINCT, ORDER BY expressions must appear in …
András Váczi's user avatar
8 votes

"ERROR:malformed array literal" when using json_to_record with a JSON array element in Postg...

Chris's answer: SELECT a, translate(b, '[]', '{}')::text[] AS b, d FROM json_to_record('{"a": 1, "b": ["hello", "There"], "c": "bar"}') AS x(a int, b text, d text); The idea is the same: massage the JSON … ) AS r(a int, b text, d text); -- versus SELECT a, translate(b, '[]', '{}')::text[] AS b, d FROM jsonb_test AS j, LATERAL json_to_record(j.data::json) AS r(a int, b text, d text); On this dataset …
András Váczi's user avatar
2 votes
Accepted

Create dynamic WHERE clause from a JSON field

For translating JSON arrays into PostgreSQL arrays, I used here a technique that is described in detail in Erwin Brandstetter's excellent answer. … Check the documentation about the different JSON(B) operators and functions. It contains quite a lot of useful stuff. …
András Váczi's user avatar
2 votes

How to retrieve the value of deleted key in jsonb?

If you want something like that, you'll first have to define the behaviour for such JSON structures. …
András Váczi's user avatar
4 votes
Accepted

Match elements of a JSON array

One way of trying to match something against array elements is using ANY. The only thing is to find the right operator that can be used with it. In this case, <@ will be our friend (you can find it …
András Váczi's user avatar
17 votes
Accepted

PostgreSQL filtering on array length inside JSON

Without knowing your data, I can only guess that the selectivity of your index is low (which happen if the length of the array does not vary much). One trick to overcome this might be changing the qu …
András Váczi's user avatar