-
Notifications
You must be signed in to change notification settings - Fork 64
Description
Current state & Rationale
Yojson currently has a semi-secret undocumented API that allows controlling the parser - when you know what the structure of the JSON is you can tell the parser what you expect and it will give you the values in a somewhat more streaming way.
The downside is that this exposes the internals of Yojson which is not great because this locks us into our current implementation. Another issue is that this code is under-used and most importantly under-tested, so improvements sometimes can break code and it doesn't get detected before the release.
Proposal
The proposal is to remove the internal code. Initially this can be just hidden from the interface and then we can shake down and rewrite the unused code.
A possible replacement for the API could be to use the Yojson.Safe.t
API. Given there are a number of consumers that convert a predefined structure from JSON to OCaml (like atdgen, ppx_deriving_yojson, ppx_yojson_conv) we could consider adding some optimized API that avoids creating a full AST but rather allows libraries to get JSON to parse with lower overhead while not exposing the internals too much.
Impact
This is under-researched at the moment, but the major consumer of this API is atdgen. mjambon suggests that atdgen could be changed to use the Yojson.Safe.t
AST.
Roadmap
This is another breaking change, so would need a dependency bump. Given a lot of code uses atdgen, a number of packages would be impacted, but once atdgen is adjusted it could generate new code that would Just Work(TM).