I see. In that case the 'groovy' way to do this is the SimpleTemplateEngine 
[1]

http://docs.groovy-lang.org/latest/html/api/groovy/text/SimpleTemplateEngine.html

Hope it helps!
Ioannis

On Thursday, February 18, 2016 at 9:47:11 AM UTC-5, Niksan wrote:
>
> Thanks for that, I'm only interested in reading though, I came up with a 
>> solution although I'm rusty with Groovy but it will make do until a better 
>> approach appears.
>>
> This method enables me to write test json in the console for test purposes.
>
> def token1 = 'Replaced-Token1'
> def token2 = 'Replaced-Token2'
>
> def tokenMapper = [
>   '${token1}' : token1,
>   '${token2}' : token2,
> ]
>
> def jsonFile = new File('d:\\test.json').text
> def json = new JsonSlurper().parseText(jsonFile)
>
> json = json*.collectAll{
>   element ->
>   if(element instanceof String) {
>     if(element.startsWith('${')) {
>       element = tokenMapper[element] ?: element
>     }
>   }
>   element
> }
>
> println(json)
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/7f6ecaf7-aa50-412d-9f8f-553375111330%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to