Repository navigation
Releases: melange-community/jsonkit
Releases · melange-community/jsonkit
Release list
jsonkit.1.1.0
- Fix the
of_jsonderiver for polymorphic variants with inherited rows, on
both backends. Decoding now tries, in this order: the type's own tags, then
the inherited types (in definition order), then the[@json.catch_all]row,
then the error (or[@json.allow_any]). It no longer depends on the row
order in the definition: an inherited type listed before an own tag used to
shadow it on Melange, and an own catch-all used to swallow every tag of the
inherited types on both backends. - Fix: use the
lenvalue as an expression on the variant case function to avoid
expected "named" value to be declared on the function. - Fix: remove the duplicated runtime deps from the ppx libraries.
- Move the JSON Schema runtime into the main packages, at
Jsonkit.Jsonschema.
It is the same API under a new path, on both backends, so sources shared
between a native and a Melange build need no per-backend conditionals. The
JSON runtime is unchanged and stays where it is: everything previously at
Jsonkit.*is still atJsonkit.*, and is now also reachable as
Jsonkit.Json.*. - Deprecate the
jsonkit.jsonschemaand
jsonkit-melange.jsonschemalibraries, along with the
Ppx_deriving_jsonschema_runtime,Ppx_deriving_jsonschema_runtime_classify
andPpx_deriving_jsonschema_runtime_primitivesmodules. They still exist and
still work, as aliases forJsonkit.Jsonschema,Jsonkit.Jsonschema.Classify
and the primitives modules. The deprecated modules keep their old shape:
Primitivesstill has itsYojsonandJsonkitsubmodules, and
json_schemais still there under that name, so existing code compiles
unchanged.
jsonkit.1.0.0
Rename the project from melange-json to jsonkit. The derivers, the runtime and the JSON Schema support all behave the same on native OCaml and on Melange, so the packages no longer lead with Melange branding: the native package takes the plain name, and the Melange package carries the suffix.
melange-json-native→jsonkit,melange-json-native.ppx→jsonkit.ppxmelange-json→jsonkit-melange,melange-json.ppx→jsonkit-melange.ppx- module
Melange_json→Jsonkit
The exposed module is Jsonkit on both backends, so sources shared between a
native and a Melange build need no per-backend conditionals. These are new
opam packages, so numbering restarts: jsonkit 1.0.0 supersedes
melange-json 2.0.0 and contains everything in it, despite the lower number.
The melange-json packages will not be updated further. (#107)
Changes:
- PPX: Creates a linter to warn about the wrong usage of [@json.name] on record fields
and [@json.key] on variant constructors. - PPX: Adds a linter that catches namespaced
json.*field attributes
([@json.name],[@json.key],[@json.default], etc.) on
[@@deriving json, jsonschema]types, to use[@name],
[@key],[@default],[@option]instead. - jsonschema: Remove the
~variant_as_stringflag; use
[@@jsonschema.compact_variants]to render payload-free constructors as
plain string constants. - PPX: Respect the
[@json.name "..."]attribute inof_jsonerror
messages. - PPX: Ignore extra JSON object fields by default in the native
PPX, matching the Melange PPX. Add[@json.disallow_extra_fields]for
records and inline records that should reject unknown keys. - PPX:
[@@deriving jsonschema]now generates
"additionalProperties": truefor records by default, matching the JSON
derivers which ignore unknown object keys. Add
[@@jsonschema.disallow_extra_fields](and
[@jsonschema.disallow_extra_fields]on inline records in variants) to opt
back into strict objects ("additionalProperties": false).
[@@jsonschema.allow_extra_fields]is still accepted for backwards
compatibility but is now a no-op; combining it withdisallow_extra_fields
is rejected. - Library: Add
Jsonkit.unknown_variant_case, a record type with
fieldstag : stringandpayload : Jsonkit.t list option,
meant to be referenced as the argument of a catch-all constructor (see
next entry). Companion JSON-schema literal
Jsonkit.unknown_variant_case_jsonschemaplugs into
ppx_deriving_jsonschema. - PPX: Add
[@json.catch_all]attribute, marking a constructor as the
catch-all for any unrecognised string tag. The constructor's argument
isJsonkit.unknown_variant_case;payloaddistinguishes bare
strings (None) from array forms (Some xs), preserving the wire
shape for round-trip-faithful decoding/encoding even when a future
producer adds payload-bearing variants. Works on both classic variants
and polymorphic variants. Pairs naturally with
[@@json.compact_variants]. - PPX: Add
[@@json.compact_variants]attribute for variant and polyvariant
types. Encodes constructors without arguments as plain JSON strings and
constructors with arguments as JSON arrays["ConstructorName", arg1, ...].
The decoder now also accepts["Tag"](singleton array) as equivalent to
"Tag"for nullary constructors, making the compact form a strict superset
of the standard array encoding. - Support
Ptype_open, e.g.type u = X.(x) [@@deriving json]
(#60) - Add support for
[@drop_default]with[@default]to omit fields
from JSON output when their value matches the default. Equality is
resolved viaequal_<type>functions in scope by default, but a custom comparison
function can be provided directly, e.g.[@json.drop_default Int.equal]
(#77) - Add
Jsonkit.equalfor comparing two JSON values, and
[@drop_default_if_json_equal]as an alternative to[@json.drop_default]
that compares values at the JSON level
(#77) - PPX: Fix
unused-varwarning with polyvars without own cases
(#38) - PPX: Add support for labeled tuples, e.g.
[%to_json: a:string * b:int],
encoded as JSON objects like records
2.0.0
CHANGES:
- [breaking] Library, PPX: Unify runtimes (
*.ppx-runtimelibraries are
removed, can usemelange-jsonandmelange-json-nativeinstead), replace
Jsonmodule withMelange_json, deprecateDecodeandEncodemodules,
introduce new decoding error type and helper function
of_json_error_to_string.
(#36) - [breaking] PPX: Code to decode polyvariants doesn't use an additional
_polyfunction which was also generated by the PPX. Instead
Unexpected_varianterror is used to signal that next decoder should be
tried. (#32) - [breaking] Json.Decode.DecodeError exception now contains a variant type
as payload instead of a string.
(#32) - [breaking] PPX: Rename
[@json.as]to[@json.name]
(#23) - [breaking] PPX: Drop special encoding for enumeration-like variants
(variants with each constructor having no arguments).
(#26) - [breaking] PPX: change JSON representation of polyvariants, make it
compatible with ppx_deriving_yojson and ppx_yojson_conv
(#27) - [breaking] PPX: Consistent use of exceptions in runtime.
(#28) - PPX:
[@@deriving json]now can be used within signatures (this includes
.mlifiles).
(#32) - PPX: Add runtime for
result
(#13) - PPX: Add
yojsonas runtime dep for the native version
(#15) - PPX: add
[@@json_string]for deriving converters to/from JSON strings
directly (#30) - PPX: add support for
int64in the runtime
(#33) - PPX: remove
string_to_jsonusage on js side
(#35) - PPX: Add array functions to native runtime
(#37)