[ 
https://issues.apache.org/jira/browse/GROOVY-11748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18017466#comment-18017466
 ] 

Eric Milles commented on GROOVY-11748:
--------------------------------------

You can replace "properties" with "get('properties')" to side-step the public 
method {{getProperties()}}.  This was a change in Groovy 5 to surface public 
fields and methods.

> Groovy JsonSlurper returns null
> -------------------------------
>
>                 Key: GROOVY-11748
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11748
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 5.0.0
>            Reporter: Ramesh Venkitaswaran
>            Priority: Major
>
> When I run my test script against Groovy 5.0.0, this returns null, whereas 
> the same script runs correctly against Groovy 4.0.28 
> {code:groovy}
> import groovy.json.*
> def url = 'https://api.weather.gov/gridpoints/TOP/31,80/forecast'
> def response = new URL(url).text
> def weather = new JsonSlurper().parseText(response)
> assert weather.properties.periods != null
> {code}
> In 5.0.0, this returns (partially reproduced), whereas in 4.0.28 it correctly 
> returns the map of the parsed json.
> {noformat}
> Exception thrown
> Assertion failed: 
> assert weather.properties.periods != null
>        |       |          |       |
>        |       |          null    false
>        |       ['JDK_MAP_ALTHASHING_SYSPROP':null, 'map':null, 'size':4, 
> 'keys':['@context', 'type', 'geometry', 'properties', null], 
> 'values':[['https://geojson.org/geojson-ld/geojson-context.jsonld', 
> ['@version':'1.1',
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to