-
Notifications
You must be signed in to change notification settings - Fork 64
Description
Current state
Yojson currently supports proprietary extensions to JSON, namely using (x, y)
syntax to represent tuples and <Bar:"abc">
for variants.
Proposal & Rationale
JSON is mainly a language-neutral format for information exchange, not much for serialization of data and as such it makes sense to support a language-interoperable set of JSON grammar. As such, outputting data using these features will yield problems with other parsers that do not understand that grammar extension.
As such the suggestion is to remove these variants from the Yojson.{Basic,Safe,Raw}.t
type, remove the pretty printing support and remove the parsing code.
Removing the code makes the maintenance easier, is simpler for people to understand (people knowing JSON might be confused why `Tuple
or `Variant
can be produced) and makes it easier to work on the parser since it can match the grammar of RFC 8259 without fitting in proprietary data types.
Impact
While this is a breaking change, we estimate the impact to be low, since presumably most JSON parsed with Yojson comes from non-OCaml sources that do not use these non-standard extensions.
The most obvious places that might break in the OCamlverse might be the schema generation tools:
ppx_deriving_yojson
does not use`Tuple
nor`Variant
, it encodes both tuples and variants as`List
sppx_yojson_conv
does not seem to use`Tuple
nor`Variant
atd
seems to encode things using`Variant
(source), but it might be possible to switch to an encoding that's more like what thederiving
-plugins do? Is there someone who we could talk on atd's behalf? @rgrinberg maybe?
Roadmap
This would be planned for a 3.0.0 release at the earliest, to give people enough time to discuss the impact and update their code. We could possibly try a rebuild of the revdeps in the duniverse to see how many projects are affected.