wanglingsong/JsonSurfer

Expose location from parsing context

devcsrj opened this issue · 2 comments

I have a use case, where I need to capture the current offset (i.e., line number, column number) in the stream from the ParsingContext. In jackson speak, this is the com.fasterxml.jackson.core.JsonLocation. I could probably capture this manually, by providing a custom JsonFactory that captures the returned parser from the createParser method (I haven't tried) so that I can query the native method.

It would be nice if this is natively supported in the ParsingContext.

I would suggest you inject the custom JsonFactory into JacksonParser. I don't think it is necessary to add such support into ParsingContext interface. JsonSurfer is designed to be decoupled so that the JsonPath processing part works consistently no matter which Json parser you choose. So it's not a good idea to add this in a common interface only for Jackson.

So it's not a good idea to add this in a common interface only for Jackson.

Oh, I didn't expect that the other libraries doesn't have a concept of locations, or at least the byte offset.

No worries!