JSON PPX derivers thread

Hello,

The ecosystem seems fractured accross ppx derivers for json.
To my knowledge, there are 3 main pps for this, by most-used to least used (according to opam data):

It looks like yet another place where the ecosystem is fractured and shouldn’t be, but the choice for a new project is not obvious. I am aware that this is not the first topic on the subject, but I thought that the discussion needs to be amplified.

First, ppx_deriving_yojson clearly asks to use ppx_yojson_conv which is more modern. However, ppx_yojson_conv has several major shortcomings, which include:

  • A major regression that has been left unfixed for the last two years
  • Important features that are not supported while ppx_deriving_yojson supports them, making ppx_yojson_conv a regression.

On its end, melange-json seems like a fine alternative, except that 1) it requires a quite heavy dependency (melange and its ecosystem), 2) it produces Js.Json.t values, and is therefore incompatible with the biggest json library in the OCaml ecosystem (Yojson), and 3) its implementation is full of calls to Obj.magic, which are probably fine in the Melange/JS ecosystem, but that I don’t really trust in OCaml. Combined, these limitations seem a bit too important.

To me, it looks like the obvious choice is to stick with ppx_deriving_yojson. If that is the case, should the warning be removed from ppx_deriving_yojson’s README, and should we make it clear to newcommers what library should be used?

Cheers!

2 Likes

I think the right place to ask this question is in a new issue in GitHub · Where software is built, if they accept that the readme recommendation is no longer valid then someone can send a PR to remove it.

I have the PR ready to be published for removing the recommendation from the README. It’s more that I’m trying to gather thoughts from the community about what they use, and it’s interesting to raise these questions to everyone rather than just the maintainers of the package.

Indeed, done. That note was added 5 years ago and simply forgotten about i think. I don’t think it reflects its current maintenance effort.

4 Likes

Amazing! Thank you very much, at least it gives a clear solution to this specific package.

I guess this thread also raises a bigger question of reducing the fracture in these choices of package. ppx_deriving_yojson is not the only case of slightly-fractured ecosystem.

1 Like

The native version is melange-json-native 2.0.0 (latest) · OCaml Package . It doesn’t depend on melange and uses yojson.

3 Likes

Oh, I did miss that information :eyes: