Re: groovy.json.JsonSulper
Søren Berg Glasius <soeren-Kc6N1ySXURF/[email protected]>
| Newsgroups | gmane.comp.lang.groovy.user |
|---|---|
| Message-ID | <CAGY+WWRibH6yFC55WbeQAYne3TyPYC10YZwwXytk-LunOjYPDw__29638.7776079186$1657018715$gmane$org@mail.gmail.com> |
First off, user questions should be sent to users-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected] not dev-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected], as the later is for the dev team to discuss the ins and outs of Groovy, I have added users-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected] to continue the conversation there Second, I just tried your code in Groovy Console on Groovy 4.0.1/Java 8 and it worked, so you need to provide more information about what version of Groovy and Java you are using. Bonus, this: def req = new URL("https://jsonplaceholder.typicode.com/todos/1 ").openConnection(); def postRC = req.getResponseCode(); def streamText = req.getInputStream().getText() can be replaced with: def streamText = 'https://jsonplaceholder.typicode.com/todos/1'.toURL().text Med venlig hilsen, Søren Berg Glasius Hedevej 1, Gl. Rye, 8680 Ry Mobile: +45 40 44 91 88 --- Press ESC once to quit - twice to save the changes. Den tir. 5. jul. 2022 kl. 12.49 skrev Dharma Teja <[email protected]>: > Hi Team, > > When I was using the below groovy script, *groovy.json.JsonSulper *was > throwing this error, Can you please help me with this > > Throws java.lang.RuntimeException: Unable to load FastStringService > > > import groovy.json.* > import java.net.http.* > def req = new URL("https://jsonplaceholder.typicode.com/todos/1 > ").openConnection(); > def postRC = req.getResponseCode(); > def streamText = req.getInputStream().getText() > def jsonSlurper = new JsonSlurper() > println streamText > def json = jsonSlurper.parseText(streamText) > println json > > > Thanks, > Teja >