michalmuskala / jason

A blazing fast JSON parser and generator in pure Elixir.
Other
1.6k stars 170 forks source link

Support exposing the position when tokenizing #116

Closed ashea-code closed 3 years ago

ashea-code commented 3 years ago

This may be a bit of an special case, but it would be fantastic if I could somehow get access to the parser's position as it decodes a JSON string. One potential use case would be pointing out issues with JSON object structure in another library (such as parsing a standardized format defined by a JSON schema file.) The positions only seem to be exposed when the parser encounters an error.

Perhaps a custom middleware-like interface that provides a configurable callback function after successfully parsing a token that passes in the token, and position?

michalmuskala commented 3 years ago

I agree this could be very useful, unfortunately I don't really see how such a flexible interface could be combined with the performance-focused nature of jason.

michalmuskala commented 3 years ago

I'm going to close this issue. If there are any suggestions how this could be handled, please reopen the issue.