I am currently working on a way to parse the output of a section of a MySQL query using Groovy's JsonSlurper.
I am trying to pull the LAT and LONG values from this query.
The query with the Json included reads fine into the database, with the expected values being returned, however, when I try and parse this Json in my JsonSlurper I get a java Missing Method exception, which complains about the parseText(). The error recommends parseText as a solution, although this is what is being used.
The error is as follows: groovy.lang.MissingMethodException: No signature of method: groovy.json.JsonSlurper.parseText() is applicable for argument types: (java.util.ArrayList)
My code is as follows:
The section of the query which produces the json is as follows:
SELECT concat('{Address:"',n.address,'",LAT:"'map.details,'",LONG:"'map.details'"}') as list FROM table
I then call the list in my JsonSlurper method, which is being populated as a database field in the application:
def result = new JsonSlurper().parseText(table.list)
def latitude = result.get("LAT")
def longitude = result.get("LONG")
println latitude
println longitude
I then plan on populating these fields in a web page, but I cannot do this until I am able to return them from the parse. The latitude and longitude values are integers, although they are parsed as strings.