
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
@glennsl/rescript-json-combinators
Advanced tools
Combinator library for JSON decoding and encoding.
Combinator library for JSON decoding and encoding.
type point = {
x: int,
y: int,
}
type polyline = {
points: array<point>,
thickness: option<int>,
}
module Decode = {
open Json.Decode
let point = object(field => {
x: field.required(. "x", int),
y: field.required(. "y", int),
})
let polyline = object(field => {
points: field.required(. "points", array(point)),
thickness: field.optional(. "thickness", int),
})
}
let data = `{
"points": [
{ "x": 1, "y": -4 },
{ "x": 5, "y": 8 }
]
}`
let _ = data->Js.Json.parseExn->Json.decode(Decode.polyline)->Js.log
See examples for more.
npm install --save @glennsl/rescript-json-combinators
Then add @glennsl/rescript-json-combinators
to bs-dependencies
in your bsconfig.json
:
{
"bs-dependencies": [
+ "@glennsl/rescript-json-combinators"
]
}
Optionally, add this to automatically open the library in order to use Json.Encode
and Json.Decode
directly:
{
"bsc-flags": [
+ "-open JsonCombinators",
]
}
rescript-json-combinators
is the spriritual successor of bs-json
. It was rewritten from scratch and not intended to be
backwards compatible. And while for the most part is does share the same design principles,there are also some notable differences:
Decoders have been made abstract. While the internal representation is still the same, a function that takes a Js.Json.t
and returns either the decoded value or raises an exception, they can no longer be called directly. Instead they have to be run
via Decode.decode
. This is in order to ensure that the DecodeError
exceptions don't leak and returns a result
instead. Custom decoders can still be created with Decode.custom
.
A new object
decoder has been added, and while it's still possible to decode fields individually in a custom decoder, this
addresses a couple ergonomic problems with that approach, such as distinguishing between a field missing and having the wrong
type, and the over-use and under-encapsulation of custom decoders.
Uncurrying and raw javascript is used in some places to improve performance. For the most part this isn't visible to the
end user because decoders can no longer be called directly. There are a couple exceptions however, such as field decoders inside
the object
deocder, and map
.
For the moment, please see the interface files:
This work is dual-licensed under LGPL 3.0 and MPL 2.0. You can choose between one of them if you use this work.
Please see LICENSE.LGPL-3.0 and LICENSE.MPL-2.0 for the full text of each license.
SPDX-License-Identifier: LGPL-3.0 OR MPL-2.0
Decode.indirect
to help with decoding recursive data structuresDecode.flatMap
Initial release
FAQs
Combinator library for JSON decoding and encoding.
The npm package @glennsl/rescript-json-combinators receives a total of 970 weekly downloads. As such, @glennsl/rescript-json-combinators popularity was classified as not popular.
We found that @glennsl/rescript-json-combinators demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.