Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save array of json object in postgres using typeorm

I am trying to save an array of object in jsonb type in postgres

Entity

@Column({type: 'jsonb', array: true, nullable: true})
testJson: object[];

The json I am sending in postman

{
    
    "testJson": [
        {"skill": "docker", "experience": true},
        {"skill": "kubernetes", "experience": false}
    ]
}

I am getting error 'malformed array literal:'

Also kindly tell if I can query such data types?

like image 811
Kallol Medhi Avatar asked Mar 24 '26 18:03

Kallol Medhi


1 Answers

I had the same problem. This worked for me

@Column('jsonb', {nullable: true})
testJson?: object[];
like image 92
naddison Avatar answered Mar 26 '26 13:03

naddison