Inconsistencies in parsing failure location reporting
Closed this issue · 1 comments
travisbrown commented
Just making a note of this so I don't forget about it.
Given some invalid JSON like this:
import jawn.{ AsyncParser, NullFacade, Parser }
import java.io.ByteArrayInputStream, java.nio.channels.Channels
val json = "[1, 2,\nx3]"
val ch = Channels.newChannel(new ByteArrayInputStream(json.getBytes))
Different Jawn parser implementations give three different locations for the failure:
scala> println(Parser.parseFromString(json)(NullFacade))
Failure(jawn.ParseException: expected json value got x (line 2, column 8))
scala> println(Parser.parseFromChannel(ch)(NullFacade))
Failure(jawn.ParseException: expected json value got x (line 2, column 2))
scala> println(Parser.async(jawn.AsyncParser.UnwrapArray)(NullFacade).absorb(json)(NullFacade))
Left(jawn.ParseException: expected json value got x (line 2, column 1))
The async parser is the only correct one.