[ https://issues.apache.org/jira/browse/GROOVY-11200?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17778302#comment-17778302 ]
ASF GitHub Bot commented on GROOVY-11200: ----------------------------------------- yuhengfdada opened a new pull request, #1972: URL: https://github.com/apache/groovy/pull/1972 # Analysis As mentioned by Paul's comment in the jira, this is a bug in `JsonParserCharArray`. The problem does not exist in `JsonParserUsingCharacterSource`. After debugging through both classes, both parser methods look exactly the same, except that `CharacterSource` would automatically add a `10`(line feed) char at the end, which triggers an exception. But for `JsonParserCharArray` it ends right at the last curly brace so the exception is overlooked. # Fix To keep the behavior consistent across `JsonParserCharArray` and `JsonParserUsingCharacterSource`, a line feed character is added to the end of the char array on initialization of `JsonParserCharArray`. # Concern Performance > JsonSlurper parses badly format JSON without throwing exception > --------------------------------------------------------------- > > Key: GROOVY-11200 > URL: https://issues.apache.org/jira/browse/GROOVY-11200 > Project: Groovy > Issue Type: Bug > Components: JSON > Affects Versions: 4.0.14 > Reporter: John Yin > Priority: Major > > JsonSlurper should throw a JsonException when parsing the following input: > {code:json} > """ > { > "a":1, > "b": { > "c":2 > }""" > {code} > > But it parses the string successfully. On the other hand, it does throw a > JsonException when parsing > > {code:json} > """ > { > "a":1, > "b": { > "c":2 > } > """ > {code} > where the ending """ is on a separate line. > > I think it should fail for both. -- This message was sent by Atlassian Jira (v8.20.10#820010)