Skip to content

Commit

Permalink
Fix parse error when Json objects or arrays ends with //, like follow…
Browse files Browse the repository at this point in the history
…ing:

{
  "arr": [
    10,
    // comment
  ],
  "n": 1,
  // Z
}

This change fixes issue yosuke-furukawa#14
  • Loading branch information
anolivetree committed Oct 22, 2021
1 parent cf7bb3f commit cb70835
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions encoding/json5/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ func stateBeginValueFromComment(s *scanner, c int) int {
case '/': // beginning of comment
s.step = stateInlineComment
return scanSkipInComment
case '}':
s.step = stateBeginStringOrEmpty
return stateBeginStringOrEmpty(s, c)
case ']':
s.step = stateBeginValueOrEmpty
return stateBeginValueOrEmpty(s, c)
}
if '1' <= c && c <= '9' { // beginning of 1234.5
s.step = state1
Expand Down

0 comments on commit cb70835

Please sign in to comment.