Questions tagged [jsonb]
Binary version of the json data type, used in Postgres 9.4+. The major practical difference is efficiency.
2,541
questions
1
vote
1
answer
61
views
Alter column type from text[] to jsonb[]
I have a text[] column which consists of elements of stringified JSON, and I want to convert it to jsonb[].
Here is my table reduced to the relevant text[] column:
CREATE TABLE certificate (
...
...
0
votes
0
answers
17
views
Postgres jsonb column crashing and corrupted "unexpected jsonb type as object key"
When querying a jsonb column, it crashes the calling code. The crash happens in TablePlus, and also from Node PG library and other Python Postgres libraries.
unexpected jsonb type as object key
No ...
0
votes
0
answers
41
views
JSONB Query for Postgresql with multiple clause and multiple condition
There is list of keys with attributes in form of json like
{
"inventory":[
{
"type": "medicine",
"name": "cipladine",
"...
0
votes
1
answer
40
views
Repeated values appear in array after updating jsonb column
I have this table:
CREATE TABLE driver_orders (
id SERIAL PRIMARY KEY,
driver_id INTEGER NOT NULL,
seats JSONB NOT NULL
)
I store this value in that table:
id
driver_id
seats
1
10029
[{"...
0
votes
1
answer
33
views
PostgreSQL | Extract value from jsonb and change its type
I have a view that contains columns from multiple tables, one of these columns is created from a value in a jsonb in another table :
CREATE VIEW my_view AS
SELECT table_1.id AS id, table_2.name AS ...
0
votes
0
answers
36
views
How to preserve the type of the members of a jsonb array?
I have this simple query :
select jsonb_path_query_first(a,'$[0]')
from (values (jsonb_build_array(1, 2, 3))) as "t" ("a")
Its working fine, but i get jsob type, when i would like ...
0
votes
0
answers
38
views
Unable to Retrieve JSONB Attribute 'gender' in JPA Query without NativeQuery
I'm facing an issue with retrieving a 'gender' attribute from a JSONB column using JPA Query in my Spring Data JPA project. I want to avoid using a native query if possible.
Im using PostgreSQL
Entity:...
0
votes
1
answer
49
views
Using MyBatis mapper.xml to increment a multiple counters in the same query inside of a JSONB field in Postgresql
I am working with Java + Spring + MyBatis + Postgresql. I have a table with a JSONB column in which there are a series of BIGINT (which are mapped to Long in Java), that for performance reason I want ...
0
votes
0
answers
18
views
AttributeConverter doesn't work with postgres jsonb, it report an error
AttributeConverter doesn't work with postgres jsonb, it report an error:
org.postgresql.util.PSQLException: ERROR: column "cloud_reminder_parameters" is of type jsonb but expression is of ...
0
votes
0
answers
38
views
Postgres jsonb with dynamic schema
I have a use case where the data of an object differ based on its type. So I want to store this data with data type jsonb. I followed this similar stack overflow answer where they have mentioned the ...
1
vote
1
answer
47
views
Select Array Element by Property Value Postgres Jsonb
I have an object stored in a jsonb column in my Postgres database.
The data in the column looks like this:
{
"results": [
{
"createdByApp": "yes",
...
0
votes
0
answers
11
views
GraphQL : `_contained_in` syntax for search matching key and value pair from jsob field
Unable to create Query for _contained_in using Hasura Graphql
_contains Query
query MyQuery($data_rule_list: jsonb) {
mbr_pgm(where: {nom_org_id: {_eq: "XXX"}, data_rule_list: {_contains: $...
-2
votes
1
answer
74
views
FOR loop inside json_build_array() function does not work
I am currently working on a function in Postgres. I have the function working, but I need to add a loop inside the json_build_array() function to add multiple of what is inside the array. This is what ...
-1
votes
1
answer
56
views
any way to fix" invalid input syntax for type json" in postgresql?
I have created a function of "login" to return me the user if match found with username or email as JSON and parameter is JSON, argument is json , all my other function work but this one is ...
0
votes
1
answer
52
views
Converting subclass to jsonb
Im new with Java, hibernate, postgres.
Im trying to write to a table with (not so much) complex data and Im keep getting exceptions. ill be happy for some guidance.
This is the table:
CREATE TABLE IF ...
-1
votes
1
answer
32
views
Does Dapper for Postgres (in C#) need a type mapper to map a List<T> to JSONB if the model itself (e.g. T) is already known?
Does Dapper need a type mapper to handle the following scenario.
Let's assume, the database (Postgres) has a column that is in JSONB: Events which in C# is a List<Event> with Event as simple as:
...
0
votes
1
answer
51
views
How to check if key value pair overlap exists in jsonb column?
I have a jsonb column in a Postgres table. It is a simple key value pair dictionary. I want to check the following:
it is a subset of a query parameter
there is overlap with query parameter
For case ...
0
votes
1
answer
29
views
Extract values from jsonb and merge in to a dataset row
tableABC
I have a PostgreS table with above structure with a JSONB column. I'm using Spring JDBC to retrieve data.
Is there a way to get the row related data in the below structure, using a SQL query....
1
vote
1
answer
61
views
How do update JSONB column array inside array using update statement
I am working on postgresql JSONB column and i want to update Array inside Array here is my json looks like this
[
{
"name": "Arjun",
"artList": [
{
"id": ...
0
votes
2
answers
69
views
Extract values from multiple nested arrays in a JSONB column
I'm currently working on a PostgreSQL query to extract specific values from a JSONB column. Here's the query I'm using:
select
a.id,
(jsonb_array_elements(a.info->'attribute1')->>'value') as ...
1
vote
2
answers
25
views
Can I use jsonb_set with the new value (3rd argument) coming from a select statement?
I have a table with a jsonb column and I want to migrate every record to a new schema.
Old schema: {"foo": "bar"}
New schema: {"foo": {"value": "bar"}
...
0
votes
3
answers
44
views
Problem with JSONB functions retrieving arrays
In a table called temporay_data with a data field called temporary_data too, filled with this JSON structure
{
"FormPayment": {
"student": [
{
&...
0
votes
0
answers
25
views
Django JSONB find value less than
I have a sample JSONB dataset below, this is one column entry from a single row:
[
{
"id": "xxx",
"type": "thing",
"value": {
&...
0
votes
1
answer
79
views
ADF mapping data flow postgres error column is of type jsonb
I am using a mapping data flow in azure data factory to copy data between two postgres databases. The table has a column with a datatype of jsonb. It looks something like this:
Create table mytable
...
0
votes
1
answer
36
views
Extract json-array for use in SELECT ... IN clause
Not sure what postgresql function should I use to extract an array from a JSONB object and use it later in select ... in clause. Preferably as a result set with one integer column.
From the json below ...
1
vote
3
answers
76
views
Querying deep nested json value from postgresql
I would like to count distinct values from someText property from nested jbson object, but I can't figure out how properly do it. Any suggestions are appreciated.
This is my jbson object
{ options: [ ...
2
votes
2
answers
99
views
Variable substitution for Postgres jsonpath operator like_regex?
I want to query a JSONB array using a regex filter. Following the docs, I should be able to do:
WHERE jsonb_path_exists(
data,
'$.value[*] ? (@ like_regex $foo flag "i")',
...
0
votes
1
answer
57
views
Update jsonb field based on string value
I have a jsonb field "formats" in "files" table that looks like this:
{
"small": {
"ext": ".jpg",
"url": "https://...
-1
votes
1
answer
112
views
enums with jsonb_accessor and rails 7.1
We have an App using the jsonb_accessor gem.
As an example we use something like this in our project.
jsonb_accessor :user_data, gender: :string
enum gender: { male: 'male', female: 'female' }
After ...
0
votes
0
answers
60
views
Hibernate 6.2.1 and json navigation @Embeddable
I am using Wildfly 28, Hibernate 6.2.1
I want to use HQL to a Json Object like in this article: Hibernate 6.2.1 and json navigation
When i add @Embeddable, the following exception is thrown on ...
0
votes
0
answers
39
views
Translate a postgresql search query to_tsquery to use criteriaBuilder
I want to take this query using full text search in postgresql and be able to write it in spring boot using the CriteriaBuilder but without the native query using jpa functions
SELECT * FROM ...
1
vote
2
answers
86
views
How to use jsonb_populate_record() to insert into a table containing an IDENTITY column
I demonstrate the issue with the following simple table. (The actual table and JSON document have a lot more fields.)
CREATE table contact (
id bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
...
-3
votes
1
answer
73
views
How to migrate jsonb data model to Diesel 2.x?
In Diesel 1.x, I defined a model that reflects a jsonb data type like this:
use diesel::pg::types::sql_types::Jsonb;
#[derive(FromSqlRow, AsExpression, serde::Serialize, serde::Deserialize, Debug, ...
0
votes
2
answers
35
views
A strange problem with PostgreSQL 15.4 jsonb_to_recordset and jsonb_populate_recordset
I have a postgresql function that takes a number of parameters, the last of which is jsonb.
It's called with the following value of parameters (double quotes due to postgres diagnostic output):
SELECT ...
-2
votes
1
answer
48
views
Springboot : How to use string type attribute in postgres Jsonb column
I am trying to use string type attribute in Entity in springboot and was trying to save it using jpa repository call "repository.save()" for postgres Jsonb column.
But getting error:
jsonb ...
0
votes
2
answers
28
views
postgres json_b array does not contain partial object
given a json_b array column named attributes that contains multiple json objects. how can i query the attributes column to get all those rows which does not have a specific value in any json object in ...
0
votes
2
answers
99
views
psycopg3 inserting dict into JSONB field
I have a table with a JSONB field and would like to insert into it using a named dict like so:
sql = "INSERT INTO tbl (id, json_fld) VALUES (%(id)s, %(json_fld)s)"
conn.execute(sql, {'id':1, ...
-1
votes
1
answer
43
views
Create jsonb data with SQL query (postgresql), then create new column with this jsonb data
I want to add a new column to the table with jsonb data(query data from other columns ).
Current table:
student_id
first_name
last_name
data_lable1
data_value1
data_lable2
data_value2
data_lable3
...
0
votes
1
answer
32
views
How to create JSONB GIN index on complex json struction
{
"elements": {
"array": [
{
"childElements": {
"array": [
{
...
0
votes
0
answers
57
views
How to pass parameter to jsonb_path_query from spring jpa data
I have spring JPA query
@Query(value = "select jsonb_path_query(payload,'$.structures.array[*].businessRelationships.array[?1]')\\:\\:text from fmk_t_contract where jsonb_path_exists(payload,'$...
0
votes
1
answer
56
views
Postgres JSONB type query from JPA
I have a table called questionnaire and it contains a column with jsonb type which is also named questionnaire. I want to do below query in using JPA.
JSON -
{"guid": "9c36adc1-7fb5-...
0
votes
1
answer
48
views
Search for multiple values within the hierarchy of the same specified folder in a flat representation of a tree structure in a Postgres jsonb table
Data structure:
The table has an PK 'id' and a jsonb column 'data'. The 'data' contains an array of objects 'instances'. Each 'instance' has some values and a 'path' array. The 'path' array is a flat ...
0
votes
1
answer
32
views
Postgresql : how to transform some columns to a json object?
I have the following results from an inner join query:
SELECT t1.id, t1.label, t2.id, t2.city, t2.ppl
FROM table1 t1
INNER JOIN table2 t2
ON t1.id = t2.country_id
t1.id
t1.label
t2.id
t2.city
t2....
1
vote
1
answer
67
views
How to avoid storing fields with null in JSONB data type
How to avoid storing fields with null value while storing into postgres JSONB data type
This is the existing code for conversion, how to make it extensible but retain the structure as well
public ...
0
votes
2
answers
150
views
What's the difference between the PostgreSQL @? and @@ JSONB Operators?
I've been trying to understand the difference between the PostgreSQL @? and @@ JSONB operators. Why do these return different results?
david=# SELECT '{ "email": { "main": "...
0
votes
1
answer
39
views
How to delete element from jsonb nested array
I have table in postgresql 13.12 with jsonb column.
Records in this column consist array of objects and looks like this:
[
{
"in": {
"categories": [
...
0
votes
0
answers
37
views
PostgreSQL & JPA - "Mixing of ? parameters and other forms is not supported" error
I have a jsonb data column with this sample data:
[
{
"eventId": "5",
"events": [
"a",
"b"
]
"customerId":&...
0
votes
2
answers
45
views
PostgreSQL: Is it possible to use the result of a subquery into a jsonb?
I have a query that gets some data, for example:
select type_of_client from table1;
type_of_client
--------------
restaurant
bar
cinema
...
And I would like to use these results into a ...
1
vote
2
answers
42
views
Insert or update object for a jsonb array in postgres
I have a table listings with a jsonb column named data.
Inside the data column I have the next structure
{
"attributes": {
"listings": [
{
"vin": &...
0
votes
1
answer
225
views
date not format as in hibernate 5 with jsonb in hibernate 6
I am migrating to quarkus 3 and i couldnt find a way to serialize properly (like in hibernate 5) my OffsetDateTime for a field annotated with jsonb in an entity :
This is one of my entity, ...