
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
github.com/fredbi/core/json
This go
library processes JSON streams and buffers.
It is intended to provide a low-level toolkit for functionally demanding use-cases involving JSON data.
It brings JSON support for go-openapi packages.
It is not a replacement for the standard library encoding/json
.
As such, it does not marshal or unmarshal your favorite go struct
to or from JSON.
It does not compete with blazingly fast JSON codec libraries, which essentially target the marshal/unmarshal feature.
Instead, it provides structures and types that keep the dynamic nature of JSON, deferring the
resolution of values to native go
types.
Essentially, it provides ways to work with JSON documents without the need of some pre-specified go
data structures.
The module github.com/fredbi/core/json
provides the following tools:
json.Unmarshal
or json.Marshal
that shuffles JSON to/from go
data structures.github.com/fredbi/core/jsonschema
.
This library focuses on low-level aspects of JSON only.github.com/fredbi/core/spec
. This is far beyond the scope of mere JSON processing.We designed this library with the goal to serve advanced use cases such as JSON schema analysis and OpenAPI spec handling.
Besides, we wanted the core of go-openapi
to avoid external dependencies for this kind of work.
Depending on your goals, you might find libraries that are a better fit for your use case.
github.com/mailru/easyjson
. However, it shares a lot of ideas with the lexer and writer from easyjson
.github.com/valyala/fastjson
or github.com/tidwall/gjson
. However, it shares a lot of ideas with fastjson
such as reusable values stored in an Arena
.encoding/json
or drop-in replacements for the standard library like github.com/go-ccy/go-json
or github.com/jsoniterator/go
.github.com/go-faster/jx
github.com/francoispqt/gojay
github.com/bytedance/sonic
(a JIT JSON serializing/deserializing lib)On the other hand, it provides a few features that you won't find in the above-mentioned libraries:
A verbatim document reproduces the original JSON unaltered, that is, including non-significant blank space used for indentation. It also leaves escaped unicode sequence unchanged.
This allows to process JSON with the ability to control the original input (as in a text editor).
In contrast, a default document focuses on JSON semantics, i.e. structure and values: non-significant blanks are ignored and the annoying escaped unicode sequences are resolved as soon a possible into their UTF-8 equivalent.
Verbatim lexer, store, document and writer should be reserved to tools like linters, text editor plugins and the like.
Documents are immutable, but cheap to build or amend using shallow clones. This guards against nasty bugs and allows for a concurrent processing of documents.
Documents maintain the original ordering of keys in objects.
Builder
typejsonpath
expressions. See github.com/fredbi/core/json/jsonpath
.This library favors accuracy over speed. It may not be the fastest JSON processor available for go
.
In particular:
At this moment, it is not a goal to support XXL documents outside of main memory, although this could be a contributed extension of the stores.Store
interface.
Likewise, it is not part of the current plan to provide writers to specialized backends such as databases or message-oriented middleware. Again, such a feature may be provided in the future as a contributed extension (while keeping our dependency-free goal).
At this moment, the scope is limited to JSON. YAML data, considered as a superset of JSON, is not part of the picture for now.
Support go-openapi
v2:
github.com/fredbi/core/jsonschema
.github.com/fredbi/core/spec
.Besides, here are a few examples of where this toolkit might be useful:
the default lexer is strict regarding JSON semantics. JSON types allow to distinguish undefined from null. ↩
the lexer does its best to report informative error messages, and capture the context of the offending part, including when dealing with streams. ↩
this leverages the memory pooling utilities exposed by github.com/fredbi/core/pools
.
By and large, the toolkit favors memory scarcity over CPU, assuming that much of the CPU-intensive processing may be deferred lazily.
For instance, th default implementation for stores.Store
compresses long strings. ↩
contrib
modules are proposed to host standalone go
modules that may bring their own set of dependencies ↩
FAQs
Unknown package
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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.