You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jörg Eichhorn (Jira)" <ji...@apache.org> on 2023/07/11 11:39:00 UTC

[jira] [Created] (GROOVY-11123) JsonLexer fails to parse number without trailing space

Jörg Eichhorn created GROOVY-11123:
--------------------------------------

             Summary: JsonLexer fails to parse number without trailing space
                 Key: GROOVY-11123
                 URL: https://issues.apache.org/jira/browse/GROOVY-11123
             Project: Groovy
          Issue Type: Bug
          Components: JSON
    Affects Versions: 4.0.13, 4.0.12, 4.0.11
            Reporter: Jörg Eichhorn


Reproducer:

 
{code:java}
reader = new StringReader('-123.456e78')
lexer = new groovy.json.JsonLexer(reader)
lexer.nextToken(){code}
Expected:

 

 
{code:java}
-123.456e78 {code}
Actual:

 

 
{code:java}
null
{code}
 

I found JsonLexerTest.groovy contains tests for plain numbers which are _surrounded by spaces_ but I wonder why this should be required?

At least it's unexpected for users like the developers of [REST-assured|https://rest-assured.io/] which pass json content from http responses without added spaces into JsonLexer (they use [their own slurper|https://github.com/rest-assured/rest-assured/blob/master/json-path/src/main/groovy/io/restassured/internal/path/json/ConfigurableJsonSlurper.groovy]). This makes REST-assured fail to support plain number responses.

One more note: Groovy's own JsonSlurper successfully parses the above example, so the behaviour is inconsistent at least.



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