groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From garneke <>
Subject Re: when does JsonSlurper return LazyMap vs LazyValueMap ?
Date Thu, 26 Jan 2017 17:30:47 GMT
-- Sorry for the first post ( formatting was lost )

Environment: groovy-all-2.4.6

In my environment I am seeing that JsonSlurper returns LazyMap in my test
code using the groovyConsole but it returns a LazyValueMap in my compiled
java code.

I am trying to add a node to the json object and it works great in the
groovyConsole but fails in java.

This code works in the groovyConsole...

 def slurper = new JsonSlurper()
 def json = slurper.parseText( jsonTxt )
 json.put("mediaHash", mediaHash)
 // -- or  --
 json."mediaHash" = mediaHash

In the  groovyConsole  slurper.parseText() returns a LazyMap
But in Java it returns a LazyValueMap and I get the exception ... die("Not
that kind of map"); 

What is the correct way to add a node and why do I get different results?

View this message in context:
Sent from the Groovy Users mailing list archive at

View raw message