How to save array of json object in postgres using typeorm

Viewed 10694

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?

1 Answers

I had the same problem. This worked for me

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