I am building a survey application in scala/play framework, and am using postgres9.4 and anorm. I am using jsonb as a datatype in other places but in one location I want to use jsonb[] thinking that this type is an array of jsonb values. My json structure is like the following:
[
{"guitar":{"passion":3,
"expertise":5,
"willingToTeach":false,
"lookingForOthers":false
}
},
{"soccer":{"passion":3,
"expertise":3,
"willingToTeach":true,
"lookingForOthers":true
}
}
]
Here each interest is a json structure. I have been able to add json response values to other columns in pgsql using jsonbas the data type, but when I try to use jsonb[] I get complaints: [PSQLException: Unknown type jsonb[].] In pgadmin3 it literally shows my this exact data type: jsonb[] for the column I am trying to insert into. In my anorm insert code I have tried setting the type:
val pgObject = new PGobject();
pgObject.setType("jsonb")
But then I get this error:
[PSQLException: ERROR: column "passions" is of type jsonb[] but expression is of type jsonb
Hint: You will need to rewrite or cast the expression.
Position: 43]
I have tried looking this up but I can't even seem to find what all string values I can use as an argument for pgObject.setType(). I am also unsure how I would go about casting the expression from jsonb to jsonb[] any other way than setting the type using the setType() method.
Any help would be greatly appreciated.
jsonb[]?jsonbhas a native array format internally. It doesn't make sense to use a PostgreSQL array ofjsonbvalues. - Craig Ringer