Fast json for go. Lightweight fork of jsoniter.

jx Go Reference codecov

Fast json for go. Lightweight fork of jsoniter.

Features

  • Reduced scope (no reflection or encoding/json adapter)
  • Fuzzing, improved test coverage
  • Drastically refactored and simplified
    • Explicit error returns
    • No Config or API

Capture

The Decoder.Capture method allows to unread everything is read in callback. This is useful for multi-pass parsing:

func TestDecoder_Capture(t *testing.T) {
	d := DecodeString(`["foo", "bar", "baz"]`)
	var elems int
	if err := d.Capture(func(d *Reader) error {
		return d.Arr(func(d *Reader) error {
			elems++
			return d.Skip()
		})
	}); err != nil {
		t.Fatal(err)
	}
	// Buffer is rolled back to state before "Capture" call:
	require.Equal(t, Array, d.Next())
	require.Equal(t, 3, elems)
}

ObjectBytes

The Decoder.ObjectBytes method tries not to allocate memory for keys, reusing existing buffer:

d := DecodeString(`{"id":1,"randomNumber":10}`)
d.ObjectBytes(func(d *Decoder, key []byte) error {
    switch string(key) {
    case "id":
    case "randomNumber":
    }
    return d.Skip()
})
Owner
ogen
OpenAPI v3 Code Generation for Go
ogen
Comments
  • chore(deps): bump github.com/go-faster/errors from 0.5.0 to 0.6.0

    chore(deps): bump github.com/go-faster/errors from 0.5.0 to 0.6.0

    Bumps github.com/go-faster/errors from 0.5.0 to 0.6.0.

    Release notes

    Sourced from github.com/go-faster/errors's releases.

    v0.6.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/go-faster/errors/compare/v0.5.0...v0.6.0

    Commits
    • fa67b69 Merge pull request #19 from tdakkota/feat/add-into-and-must
    • b53f5de feat: add Into and Must generic helpers
    • bef5a9b chore: bump Go version requirement to 1.18
    • 01fe582 ci: use x
    • 244984d Merge pull request #18 from go-faster/dependabot/github_actions/wagoid/commit...
    • bb5994e build(deps): bump wagoid/commitlint-github-action from 4.1.10 to 4.1.11
    • f7f0b01 Merge pull request #17 from go-faster/dependabot/github_actions/codecov/codec...
    • b9aa4bf build(deps): bump codecov/codecov-action from 2.1.0 to 3
    • 246ca19 Merge pull request #16 from go-faster/dependabot/github_actions/wagoid/commit...
    • 455cae5 build(deps): bump wagoid/commitlint-github-action from 4.1.9 to 4.1.10
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • feat: array iterator

    feat: array iterator

    name                     time/op
    DecodeBools/Callback-12   1.67µs ± 3%
    DecodeBools/Iterator-12   1.47µs ± 1%
    
    name                     speed
    DecodeBools/Callback-12  574MB/s ± 3%
    DecodeBools/Iterator-12  651MB/s ± 2%
    
  • feat: improve string encoding

    feat: improve string encoding

    Benchstat result:

    name                           old time/op    new time/op    delta
    EncoderBigObject-12              7.56µs ± 2%    4.01µs ± 1%  -46.97%  (p=0.000 n=10+10)
    Encoder_Field/1/Manual-12        20.6ns ± 2%    18.6ns ± 0%   -9.83%  (p=0.000 n=10+9)
    Encoder_Field/1/Callback-12      26.2ns ± 5%    24.8ns ± 5%   -5.20%  (p=0.034 n=10+10)
    Encoder_Field/5/Manual-12        84.3ns ± 1%    81.9ns ± 0%   -2.89%  (p=0.000 n=10+9)
    Encoder_Field/5/Callback-12       112ns ± 4%     126ns ± 1%  +12.43%  (p=0.000 n=10+10)
    Encoder_Field/10/Manual-12        173ns ± 1%     150ns ± 0%  -13.15%  (p=0.000 n=10+9)
    Encoder_Field/10/Callback-12      200ns ± 2%     182ns ± 1%   -9.30%  (p=0.000 n=9+10)
    Encoder_Field/100/Manual-12      1.62µs ± 1%    1.39µs ± 0%  -13.91%  (p=0.000 n=10+9)
    Encoder_Field/100/Callback-12    1.86µs ± 1%    1.65µs ± 0%  -11.15%  (p=0.000 n=10+10)
    
    name                           old speed      new speed      delta
    EncoderBigObject-12             674MB/s ± 2%  1271MB/s ± 1%  +88.57%  (p=0.000 n=10+10)
    
  • chore(deps): bump actions/cache from 2.1.6 to 2.1.7

    chore(deps): bump actions/cache from 2.1.6 to 2.1.7

    Bumps actions/cache from 2.1.6 to 2.1.7.

    Release notes

    Sourced from actions/cache's releases.

    v2.1.7

    Support 10GB cache upload using the latest version 1.0.8 of @actions/cache

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • chore(deps): bump github.com/stretchr/testify from 1.8.0 to 1.8.1

    chore(deps): bump github.com/stretchr/testify from 1.8.0 to 1.8.1

    Bumps github.com/stretchr/testify from 1.8.0 to 1.8.1.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • chore(deps): bump github.com/stretchr/testify from 1.7.5 to 1.8.0

    chore(deps): bump github.com/stretchr/testify from 1.7.5 to 1.8.0

    Bumps github.com/stretchr/testify from 1.7.5 to 1.8.0.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • chore(deps): bump github.com/stretchr/testify from 1.7.4 to 1.7.5

    chore(deps): bump github.com/stretchr/testify from 1.7.4 to 1.7.5

    Bumps github.com/stretchr/testify from 1.7.4 to 1.7.5.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • fix: parse Num correctly

    fix: parse Num correctly

    name                         old time/op    new time/op    delta
    Decoder_Num/Number/Buffer-4    36.1ns ± 2%    41.4ns ± 2%   +14.55%  (p=0.000 n=15+15)
    Decoder_Num/Number/Reader-4     112ns ± 4%     181ns ± 2%   +62.01%  (p=0.000 n=14+15)
    Decoder_Num/String/Buffer-4    43.7ns ± 5%    55.1ns ± 1%   +26.15%  (p=0.000 n=14+13)
    Decoder_Num/String/Reader-4     142ns ± 1%      75ns ± 6%   -47.13%  (p=0.000 n=13+13)
    
    name                         old alloc/op   new alloc/op   delta
    Decoder_Num/Number/Buffer-4     0.00B          0.00B           ~     (all equal)
    Decoder_Num/Number/Reader-4     16.0B ± 0%     64.0B ± 0%  +300.00%  (p=0.000 n=15+15)
    Decoder_Num/String/Buffer-4     0.00B          0.00B           ~     (all equal)
    Decoder_Num/String/Reader-4     24.0B ± 0%      0.0B       -100.00%  (p=0.000 n=15+15)
    
    name                         old allocs/op  new allocs/op  delta
    Decoder_Num/Number/Buffer-4      0.00           0.00           ~     (all equal)
    Decoder_Num/Number/Reader-4      1.00 ± 0%      2.00 ± 0%  +100.00%  (p=0.000 n=15+15)
    Decoder_Num/String/Buffer-4      0.00           0.00           ~     (all equal)
    Decoder_Num/String/Reader-4      2.00 ± 0%      0.00       -100.00%  (p=0.000 n=15+15)
    
  • chore(deps): bump github.com/stretchr/testify from 1.7.2 to 1.7.4

    chore(deps): bump github.com/stretchr/testify from 1.7.2 to 1.7.4

    Bumps github.com/stretchr/testify from 1.7.2 to 1.7.4.

    Commits
    • 48391ba Fix panic in AssertExpectations for mocks without expectations (#1207)
    • 840cb80 arrays value types in a zero-initialized state are considered empty (#1126)
    • 07dc7ee Bump actions/setup-go from 3.1.0 to 3.2.0 (#1191)
    • c33fc8d Bump actions/checkout from 2 to 3 (#1163)
    • 3c33e07 Added Go 1.18.1 as a build/supported version (#1182)
    • e2b56b3 Bump github.com/stretchr/objx from 0.1.0 to 0.4.0
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • chore(deps): bump github.com/stretchr/testify from 1.7.1 to 1.7.2

    chore(deps): bump github.com/stretchr/testify from 1.7.1 to 1.7.2

    Bumps github.com/stretchr/testify from 1.7.1 to 1.7.2.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • chore(deps): bump github.com/segmentio/asm from 1.1.5 to 1.2.0

    chore(deps): bump github.com/segmentio/asm from 1.1.5 to 1.2.0

    Bumps github.com/segmentio/asm from 1.1.5 to 1.2.0.

    Release notes

    Sourced from github.com/segmentio/asm's releases.

    v1.2.0

    What's Changed

    Full Changelog: https://github.com/segmentio/asm/compare/v1.1.5...v1.2.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • idea: provide fast encoders and decoders for popular types

    idea: provide fast encoders and decoders for popular types

    Provide fast decoder for UUIDs, time.Time, netip.IP, etc. May be useful for ogen purposes.

    See encoding/decoding optimization for UUID https://github.com/ogen-go/ogen/pull/98.

  • test: cleanup

    test: cleanup

    • [x] Use Go test naming convention (TestDecoder_Skip instead of Test_skip)
    • [ ] Unify benchmarks and delete duplicates (BenchmarkValid vs BenchmarkSkip)
    • [x] Populate testdata with different cases (real world objects, big array of primitives, use some benchmark sets)
      • #12 (added floats.json)
      • #15 (added small/medium/large/etc)
      • #18 (added bools.json and nulls.json)
      • https://github.com/go-faster/jx/commit/e00d36c7cc43d995161f8cc4aca458573bdd3bb5 (added corpus from JSONTestSuite)
    • [x] Use table tests, generate cases for in-memory and streaming decoding
Related tags
Fast JSON encoder/decoder compatible with encoding/json for Go
Fast JSON encoder/decoder compatible with encoding/json for Go

Fast JSON encoder/decoder compatible with encoding/json for Go

Jan 6, 2023
JSON Spanner - A Go package that provides a fast and simple way to filter or transform a json document

JSON SPANNER JSON Spanner is a Go package that provides a fast and simple way to

Sep 14, 2022
Get JSON values quickly - JSON parser for Go
Get JSON values quickly - JSON parser for Go

get json values quickly GJSON is a Go package that provides a fast and simple way to get values from a json document. It has features such as one line

Dec 28, 2022
JSON diff library for Go based on RFC6902 (JSON Patch)

jsondiff jsondiff is a Go package for computing the diff between two JSON documents as a series of RFC6902 (JSON Patch) operations, which is particula

Dec 4, 2022
Package json implements encoding and decoding of JSON as defined in RFC 7159

Package json implements encoding and decoding of JSON as defined in RFC 7159. The mapping between JSON and Go values is described in the documentation for the Marshal and Unmarshal functions

Jun 26, 2022
Json-go - CLI to convert JSON to go and vice versa
Json-go - CLI to convert JSON to go and vice versa

Json To Go Struct CLI Install Go version 1.17 go install github.com/samit22/js

Jul 29, 2022
Fast JSON parser and validator for Go. No custom structs, no code generation, no reflection

fastjson - fast JSON parser and validator for Go Features Fast. As usual, up to 15x faster than the standard encoding/json. See benchmarks. Parses arb

Jan 5, 2023
Fast and flexible JSON encoder for Go
Fast and flexible JSON encoder for Go

Jettison Jettison is a fast and flexible JSON encoder for the Go programming language, inspired by bet365/jingo, with a richer features set, aiming at

Dec 21, 2022
Fast JSON serializer for golang.

easyjson Package easyjson provides a fast and easy way to marshal/unmarshal Go structs to/from JSON without the use of reflection. In performance test

Jan 4, 2023
Fast Color JSON Marshaller + Pretty Printer for Golang
Fast Color JSON Marshaller + Pretty Printer for Golang

ColorJSON: The Fast Color JSON Marshaller for Go What is this? This package is based heavily on hokaccha/go-prettyjson but has some noticible differen

Dec 19, 2022
A fast json parser for go

rjson rjson is a json parser that relies on Ragel-generated state machines for most parsing. rjson's api is minimal and focussed on efficient parsing.

Sep 26, 2022
A blazingly fast JSON serializing & deserializing library
A blazingly fast JSON serializing & deserializing library

Sonic A blazingly fast JSON serializing & deserializing library, accelerated by JIT(just-in-time compiling) and SIMD(single-instruction-multi-data). B

Jan 5, 2023
Kazaam was created with the goal of supporting easy and fast transformations of JSON data with Golang

kazaam Description Kazaam was created with the goal of supporting easy and fast transformations of JSON data with Golang. This functionality provides

Sep 17, 2021
Abstract JSON for golang with JSONPath support

Abstract JSON Abstract JSON is a small golang package provides a parser for JSON with support of JSONPath, in case when you are not sure in its struct

Jan 5, 2023
Small utility to create JSON objects
Small utility to create JSON objects

gjo Small utility to create JSON objects. This was inspired by jpmens/jo. Support OS Mac Linux Windows Requirements Go 1.1.14~ Git Installtion Build $

Dec 8, 2022
A Go package for handling common HTTP JSON responses.

go-respond A Go package for handling common HTTP JSON responses. Installation go get github.com/nicklaw5/go-respond Usage The goal of go-respond is to

Sep 26, 2022
JSON query in Golang

gojq JSON query in Golang. Install go get -u github.com/elgs/gojq This library serves three purposes: makes parsing JSON configuration file much easie

Dec 28, 2022
Automatically generate Go (golang) struct definitions from example JSON

gojson gojson generates go struct definitions from json or yaml documents. Example $ curl -s https://api.github.com/repos/chimeracoder/gojson | gojson

Jan 1, 2023
A JSON diff utility

JayDiff A JSON diff utility. Install Downloading the compiled binary Download the latest version of the binary: releases extract the archive and place

Dec 11, 2022