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

ASF GitHub Bot commented on GROOVY-7630:
----------------------------------------

GitHub user jwagenleitner opened a pull request:

    https://github.com/apache/incubator-groovy/pull/189

    GROOVY-7630 - JsonSlurper LAX parser with invalid number

    Breaking changes proposed here, but current behavior appears incorrect even 
in terms of relaxed parsing.  In addition to addressing GROOVY-7630, also found 
some missing cases around decimal parsing which were partially addressed by 
commit 8063a9dec07329804f3e1770aa31984bc38a694d for GROOVY-7344.
    
    There seems to be quite a bit of duplication between the LAX and 
INDEX_OVERLAY parsers that I didn't address in this PR (actually adding more 
duplication :smile:).  I didn't want to introduce too much change, but at some 
point would like to come back and remove the duplication.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jwagenleitner/incubator-groovy GROOVY-7630

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-groovy/pull/189.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #189
    
----
commit 7bb1bdc0611d10605b0c9c441c9d3414fbc7b282
Author: John Wagenleitner <john.wagenleit...@gmail.com>
Date:   2015-11-15T07:08:04Z

    GROOVY-7630 - JsonSlurper LAX parser with invalid number

----


> JsonSlurper LAX parser with invalid number
> ------------------------------------------
>
>                 Key: GROOVY-7630
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7630
>             Project: Groovy
>          Issue Type: Bug
>          Components: JSON
>    Affects Versions: 2.4.5
>         Environment: DISTRIB_ID=Ubuntu
> DISTRIB_RELEASE=14.10
> DISTRIB_CODENAME=utopic
> DISTRIB_DESCRIPTION="Ubuntu 14.10"
> Linux 3.16.0-44-generic x86_64
>            Reporter: Alan Hengle
>            Priority: Minor
>
> The JsonSlurper LAX parser parses an invalid number incorrectly:
> {code:title=Example.java|borderStyle=solid}
> import groovy.json.*
> def obj = new JsonSlurper().setType(JsonParserType.LAX).parseText('{ "num": 
> 1a}')
> println "1a: num = ${obj.num}"
> println "1a: type is " + obj.num.class.name
> obj = new JsonSlurper().setType(JsonParserType.LAX).parseText('{ "num": 1A}')
> println "1A: num = ${obj.num}"
> println "1A: type is " + obj.num.class.name
> {code}
> produces:
> 1a: num = 59
> 1a: type is java.lang.Integer
> 1A: num = 27
> 1A: type is java.lang.Integer
> It seems like the parser should fail this as an invalid number, though one 
> could argue the LAX parser could interpret it as hex 1a, but neither is being 
> done.  Valid numbers are of course parsed correctly.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to