cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting error "org.json.JSONObject cannot be cast to java.lang.String" while inserting into postgreSQL using json_populate_record function

sbt
Amethyst

Getting error "org.json.JSONObject cannot be cast to java.lang.String" while inserting into postgreSQL using json_populate_record function

Hello ,

I am getting error "org.json.JSONObject cannot be cast to java.lang.String" when i run the service.

input given = {"formulaexp":"(2*3)","outputtag":"test","displayunit":"testunit","attributearray":"{abc,efg,hij}"}

but the same input works when i execute in query analyser

Thanks

Sunay

Tags (1)
6 REPLIES 6

Re: Getting error "org.json.JSONObject cannot be cast to java.lang.String" while inserting into postgreSQL using json_populate_record function

Sunay, have you tried replacing the [[...]] with <<...>>> ?

Re: Getting error "org.json.JSONObject cannot be cast to java.lang.String" while inserting into postgreSQL using json_populate_record function

sushant,

Yes but get the below error

Error executing service

Unable to Invoke Service TestInsertExpression on AlgorithmConfigratorDB : ERROR: syntax error at or near "{" Position: 185

Script

insert into Formula_Template(FormulaExp,OutputTag,DisplayUnit,AttributeArray)

select FormulaExp,OutputTag,DisplayUnit,AttributeArray from json_populate_record(null::Formula_Template, <<inputJSON>>)

Thanks

Sunay

Re: Getting error "org.json.JSONObject cannot be cast to java.lang.String" while inserting into postgreSQL using json_populate_record function

Against which database are you running this query? Just want to recheck the syntax of SQL you have there, from the screenshot above it looks like PostgerSQL, but could you please confirm.

Re: Getting error "org.json.JSONObject cannot be cast to java.lang.String" while inserting into postgreSQL using json_populate_record function

Its PostgreSQL.

Re: Getting error "org.json.JSONObject cannot be cast to java.lang.String" while inserting into postgreSQL using json_populate_record function

Sushanth,

any suggestion on what i am missing in the syntax..?

Thanks

Sunay

Re: Getting error "org.json.JSONObject cannot be cast to java.lang.String" while inserting into postgreSQL using json_populate_record function

one more question have you tested with INPUT parameter of type String instead of JSON?