Skip to main content
15-Moonstone
October 25, 2017
Question

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

  • October 25, 2017
  • 1 reply
  • 5705 views

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

1 reply

5-Regular Member
October 26, 2017

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

sbt15-MoonstoneAuthor
15-Moonstone
October 26, 2017

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

5-Regular Member
October 26, 2017

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.