cancel
Showing results for 
Search instead for 
Did you mean: 

JsonSlurper

SOLVED
Contributor

JsonSlurper

Hello,

I was previously using the groovy class JsonSlurper to edit a json before sending it to REST web services

 

seems that the class is no more supported

 

what is the workaround to do the same thing

- create a json object using template string

- modifying the json structure

- sending the json string to web service

thank you

regards

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Contributor

Re: JsonSlurper

Have you imported JsonSlurper into your script with:

import groovy.json.JsonSlurper

 

Mo

If my answer helped you out, please consider leaving kudos and/or accepting as a solution.
Have an awesome day!
4 REPLIES 4
Contributor

Re: JsonSlurper

Hi there,

 

As far as I can tell JsonSlurper is still supported by groovy

Could you give any more information on your issue?

 

Mo

If my answer helped you out, please consider leaving kudos and/or accepting as a solution.
Have an awesome day!
Contributor

Re: JsonSlurper

Hi, thanks for your help

my groovy code is very simple

...

def slurper = new JsonSlurper()
def object = slurper.parseText(jsonAsText)
object.name = context.servername1

 

I receive now an error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script14.groovy: 36: unable to resolve class JsonSlurper @ line 36, column 15. def slurper = new JsonSlurper() ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class JsonSlurper @ line 36, column 15. at

 

I saw in a post a ne class jsonUtils introduced in 2.4, I can parse json but not modify it

 

Do you have an idea ?

 

Contributor

Re: JsonSlurper

Have you imported JsonSlurper into your script with:

import groovy.json.JsonSlurper

 

Mo

If my answer helped you out, please consider leaving kudos and/or accepting as a solution.
Have an awesome day!
Contributor

Re: JsonSlurper

Hi,

Thank  you, I finally found the complete solution using jsonslurper (with the right import Smiley Happy) and jsonbuilder

Thanks for your help

Regards

New Here?
Join us and watch the welcome video:
Top Kudoed Authors