You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by kr...@gmail.com,
kr...@gmail.com on 2018/10/10 10:31:29 UTC
asset does not produce any output -am i missing something
Hi the following lines of code does not produce anything
package com.mds2.automation
import groovy.json.JsonSlurper
def jsonSlurper = new JsonSlurper()
def object1 = jsonSlurper.parseText('{"name" : "abc", "value": "123", "field" : "xyz"}')
def object2 =jsonSlurper.parseText('{"field" : "xyz", "value": "123" ,"name" : "abc"}')
assert object1 instanceof Map
I cant see any output in the console , I would expect a response of 'false'
Re: asset does not produce any output -am i missing something
Posted by Jesper Steen Møller <je...@selskabet.org>.
Hi Krishnan,
> On 10 Oct 2018, at 12.31, krishnandoss08@gmail.com wrote:
>
> Hi the following lines of code does not produce anything
> package com.mds2.automation
>
> import groovy.json.JsonSlurper
> def jsonSlurper = new JsonSlurper()
> def object1 = jsonSlurper.parseText('{"name" : "abc", "value": "123", "field" : "xyz"}')
> def object2 =jsonSlurper.parseText('{"field" : "xyz", "value": "123" ,"name" : "abc"}')
>
> assert object1 instanceof Map
>
> I cant see any output in the console , I would expect a response of 'false'
assert doesn't produce values, it's a statement.
If you try just
object1 instanceof Map
You should get the expected "true" (since parseText will parse JSON into a groovy.json.internal.LazyMap)
HTH!
-Jesper