I wanted to keep the feature tracking issue clean but feel free to open a separate issue if you have suggestions!
It is indeed a concern. I’m not sure exactly what’s the best way to handle those but I like the idea of the or-pattern with permutations because it would compose nicely with a binding anti-quotation extension. It could indeed be heavy for objects with an important number of fields. I assume most yojson users also use
ppx_deriving_yojson which would prevent from the need of writing pattern-matching on such large json objects by hand.
In fact I’m not 100% sold on the value of a pattern extension. The only cases where I write a pattern-matching on a Yojson value are parsers that need to be retro-compatible with older format and usually look like:
let of_yojson = function
| `List _ as json -> legacy_of_yojson json
| json -> of_yojson json
if it used to be represented as a json array and is now represented as a json string for instance. In such cases the ppx version of it would most likely be longer than the original.
I still want to do it though. If it turns out to be really useful to someone then it’s great and I’d be happy to discuss their specific use case and needs.