Parsing posgresql data in katalon

I’m trying to parse selected result from PostgreeSQL in Groovy, but something goes wrong, when I’m trying to parse it. I used a lot of things, but I haven’t reached the goal. I’ve tried so: I have three columns in postgre. One of the columns (document) is jsonb type and I want to parse it.

//instance of connection string to postrgre

PgAdmin pg = new 
List<GroovyRowResult> result = pg.getSelectResult(Here goes select script)
for(Map oneRow in result) {
def document = oneRow.get("document")
println documnet //Well from here it works good, it prints jsonb data stored in document column.
def customerName = document.get("CustomerName") // it failes and goes on error, where CustomerName is inside jsonB.
}

I’ve also tried to use JsonSlurper, but it also fails.

Reason:
groovy.lang.MissingMethodException: No signature of method: groovy.json.JsonSlurper.parseText() is applicable for argument types: (org.postgresql.util.PGobject) values: ....

hi,

you have to parse your json result before using it
https://groovy-lang.org/json.html

1 Like