groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From garneke <kenton.gar...@issinc.com>
Subject RE: when does JsonSlurper return LazyMap vs LazyValueMap ?
Date Thu, 26 Jan 2017 20:27:23 GMT
Update:
I have determined that the difference in the return type has to do with the JsonSlurper type.
 The INDEX_OVERLAY returns a LazyValueMap.

That being said...
What is the correct way to add a node or otherwise modify the LazyValueMap objects?


From: garneke [via Groovy] [mailto:ml-node+s329449n5738133h55@n5.nabble.com]
Sent: Thursday, January 26, 2017 12:31 PM
To: Kenton Garner <kenton.garner@issinc.com>
Subject: Re: when does JsonSlurper return LazyMap vs LazyValueMap ?

-- 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?
Thanks

________________________________
If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/when-does-JsonSlurper-return-LazyMap-vs-LazyValueMap-tp5738132p5738133.html
To unsubscribe from when does JsonSlurper return LazyMap vs LazyValueMap ?, click here<http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5738132&code=a2VudG9uLmdhcm5lckBpc3NpbmMuY29tfDU3MzgxMzJ8LTIwMjIyNDI3NDY=>.
NAML<http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://groovy.329449.n5.nabble.com/when-does-JsonSlurper-return-LazyMap-vs-LazyValueMap-tp5738132p5738141.html
Sent from the Groovy Users mailing list archive at Nabble.com.
Mime
View raw message