Just some points of clarification. * JsonSlurper isn't a static class - no change with respect to its definition has been made across Groovy3 and 4 apart from the package renaming to comply with the JPMS split packaging requirements for JDK9+. * JsonSlurper doesn't parse into an org.json.JSONObject. It has its own LazyMap. * The LazyMap is backed by an ordered map unless you are using JDK1.6 and earlier or 1.7 and don't have the "jdk.map.althashing.threshold" property set. There were known inefficiencies in LinkedHashMap in those old (> 10 yrs ago) JDKs.
Cheers, Paul. On Sat, Jul 9, 2022 at 1:37 AM Owen Rubel <oru...@gmail.com> wrote: > > So JSONSlurper is now a static class but I would warn against using > JSONSlurper in some cases as it doesn't maintain ORDER in lists when parsing > JSON. > > This is a known BUG. But there is a simple solution; JSONSlurper parses into > a org.json.JSONObjectand as such, you can easily parse your JSON by simply > using JSONObject(text) to parse your text > > Owen Rubel > oru...@gmail.com > > > On Fri, Jul 8, 2022 at 4:10 AM Tommy Svensson <to...@natusoft.se> wrote: >> >> Hello Groovy people, >> >> I have code using org.apache.groovy:groovy:4.0.1 and it builds without any >> problems. >> >> But now I want to use the JSONSlurper and it looks like there is a new >> JSONParser also. That however requires groovy-all from googling. The problem >> is that there seem to be not groovy-all for version 4.0.1. Maven completely >> fails when I add "-all" to "groovy" in my poms. It will not download the >> groovy-all file. I deleted ~/.m2/repository and built again and it >> downloaded all but groovy-all. >> >> The JSON stuff is not available in the "groovy" artifact. >> >> So my question really is, I want to use Groovys JSON features, what do I >> need to do to accomplish that ? >> >> I've completely failed top find any Groovy 4.0 related page other than the >> release notes. Since there are big diffs between versions there must be some >> page for each version I assume ? >> >> I found this: https://groovy-lang.org/processing-json.html but it is not >> version specific and provides no information on how to get access to it. >> >> I'm frustrated. Something seemingly simple turned out to be the opposite! >> >> Any help is appreciated. >> >> Thanks, >> Tommy Svensson >> >> >>