json encoding and decoding

Overview

jx beta

Package jx implements encoding and decoding of json [RFC 7159]. Lightweight fork of jsoniter.

go get github.com/go-faster/jx

Features

  • Directly encode and decode json values
  • No reflect or interface{}
  • Pools and direct buffer access for less (or none) allocations
  • Multi-pass decoding
  • Validation

See usage for examples. Mostly suitable for fast low-level json manipulation with high control. Used in ogen project for json (un)marshaling code generation based on json and OpenAPI schemas.

Why

Most of jsoniter issues are caused by necessity to be drop-in replacement for standard encoding/json. Removing such constrains greatly simplified implementation and reduced scope, allowing to focus on json stream processing.

  • Commas are handled automatically while encoding
  • Raw json, Number and Base64 support
  • Reduced scope
    • No reflection
    • No encoding/json adapter
    • 3.5x less code (8.5K to 2.4K SLOC)
  • Fuzzing, improved test coverage
  • Drastically refactored and simplified
    • Explicit error returns
    • No Config or API

Usage

Decode

Use jx.Decoder. Zero value is valid, but constructors are available for convenience:

To reuse decoders and their buffers, use jx.GetDecoder and jx.PutDecoder alongside with reset functions:

Decoder is reset on PutDecoder.

d := jx.DecodeStr(`{"values":[4,8,15,16,23,42]}`)

// Save all integers from "values" array to slice.
var values []int

// Iterate over each object field.
if err := d.Obj(func(d *jx.Decoder, key string) error {
    switch key {
    case "values":
        // Iterate over each array element.
        return d.Arr(func(d *jx.Decoder) error {
            v, err := d.Int()
            if err != nil {
                return err
            }
            values = append(values, v)
            return nil
        })
    default:
        // Skip unknown fields if any.
        return d.Skip()
    }
}); err != nil {
    panic(err)
}

fmt.Println(values)
// Output: [4 8 15 16 23 42]

Encode

Use jx.Encoder. Zero value is valid, reuse with jx.GetEncoder, jx.PutEncoder and jx.Encoder.Reset(). Encoder is reset on PutEncoder.

var e jx.Encoder
e.ObjStart()           // {
e.FieldStart("values") // "values":
e.ArrStart()           // [
for _, v := range []int{4, 8, 15, 16, 23, 42} {
    e.Int(v)
}
e.ArrEnd() // ]
e.ObjEnd() // }
fmt.Println(e)
fmt.Println("Buffer len:", len(e.Bytes()))
// Output: {"values":[4,8,15,16,23,42]}
// Buffer len: 28

Raw

Use jx.Decoder.Raw to read raw json values, similar to json.RawMessage.

d := jx.DecodeStr(`{"foo": [1, 2, 3]}`)

var raw jx.Raw
if err := d.Obj(func(d *jx.Decoder, key string) error {
    v, err := d.Raw()
    if err != nil {
        return err
    }
    raw = v
    return nil
}); err != nil {
    panic(err)
}

fmt.Println(raw.Type(), raw)
// Output:
// array [1, 2, 3]

Number

Use jx.Decoder.Num to read numbers, similar to json.Number. Also supports number strings, like "12345", which is common compatible way to represent uint64.

d := jx.DecodeStr(`{"foo": "10531.0"}`)

var n jx.Num
if err := d.Obj(func(d *jx.Decoder, key string) error {
    v, err := d.Num()
    if err != nil {
        return err
    }
    n = v
    return nil
}); err != nil {
    panic(err)
}

fmt.Println(n)
fmt.Println("positive:", n.Positive())

// Can decode floats with zero fractional part as integers:
v, err := n.Int64()
if err != nil {
    panic(err)
}
fmt.Println("int64:", v)
// Output:
// "10531.0"
// positive: true
// int64: 10531

Base64

Use jx.Encoder.Base64 and jx.Decoder.Base64 or jx.Decoder.Base64Append.

Same as encoding/json, base64.StdEncoding or [RFC 4648].

var e jx.Encoder
e.Base64([]byte("Hello"))
fmt.Println(e)

data, _ := jx.DecodeBytes(e.Bytes()).Base64()
fmt.Printf("%s", data)
// Output:
// "SGVsbG8="
// Hello

Validate

Check that byte slice is valid json with jx.Valid:

fmt.Println(jx.Valid([]byte(`{"field": "value"}`))) // true
fmt.Println(jx.Valid([]byte(`"Hello, world!"`)))    // true
fmt.Println(jx.Valid([]byte(`["foo"}`)))            // false

Capture

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

d := jx.DecodeStr(`["foo", "bar", "baz"]`)
var elems int
// NB: Currently Capture does not support io.Reader, only buffers.
if err := d.Capture(func(d *jx.Decoder) error {
	// Everything decoded in this callback will be rolled back.
	return d.Arr(func(d *jx.Decoder) error {
		elems++
		return d.Skip()
	})
}); err != nil {
	panic(err)
}
// Decoder is rolled back to state before "Capture" call.
fmt.Println("Read", elems, "elements on first pass")
fmt.Println("Next element is", d.Next(), "again")

// Output:
// Read 3 elements on first pass
// Next element is array again

ObjBytes

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

d := DecodeStr(`{"id":1,"randomNumber":10}`)
d.ObjBytes(func(d *Decoder, key []byte) error {
    switch string(key) {
    case "id":
    case "randomNumber":
    }
    return d.Skip()
})

Roadmap

  • Rework and export Any
  • Support Raw for io.Reader
  • Support Capture for io.Reader
  • Improve Num
    • Better validation on decoding
    • Support BigFloat and BigInt
    • Support equivalence check, like eq(1.0, 1) == true
  • Add non-callback decoding of objects

Non-goals

  • Code generation for decoding or encoding
  • Replacement for encoding/json
  • Reflection or interface{} based encoding or decoding
  • Support for json path or similar

This package should be kept as simple as possible and be used as low-level foundation for high-level projects like code generator.

License

MIT, same as jsoniter

Issues
  • 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)
    dependencies go 
    opened by dependabot[bot] 2
  • 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%
    
    opened by tdakkota 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)
    
    opened by tdakkota 2
  • 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)
    dependencies github_actions 
    opened by dependabot[bot] 2
  • 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)
    dependencies go 
    opened by dependabot[bot] 1
  • 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)
    dependencies go 
    opened by dependabot[bot] 1
  • 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)
    
    opened by tdakkota 1
  • 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)
    dependencies go 
    opened by dependabot[bot] 1
  • 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)
    dependencies go 
    opened by dependabot[bot] 1
  • 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)
    dependencies go 
    opened by dependabot[bot] 1
  • chore(deps): bump github.com/segmentio/asm from 1.1.4 to 1.1.5

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

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

    Commits
    • 0eb1ec1 .github: run benchmarks in CI environment
    • aee0221 qsort: add benchmarks from the standard library
    • 3e23660 go.mod: update /x/sys to latest version
    • 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)
    dependencies go 
    opened by dependabot[bot] 1
  • 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.

    enhancement 
    opened by tdakkota 0
  • 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
    good first issue 
    opened by tdakkota 0
Releases(v0.39.0)
  • v0.39.0(Aug 7, 2022)

    What's Changed

    • ci: they finally did it by @tdakkota in https://github.com/go-faster/jx/pull/64
    • chore: drop go1.17 by @ernado in https://github.com/go-faster/jx/pull/65

    Full Changelog: https://github.com/go-faster/jx/compare/v0.38.1...v0.39.0

    Source code(tar.gz)
    Source code(zip)
  • v0.38.1(Jul 15, 2022)

    What's Changed

    • fix: do not reference buffer for key if decoder is buffered by @tdakkota in https://github.com/go-faster/jx/pull/63
    • test(fuzz): add FuzzDecEncReader by @ernado in https://github.com/go-faster/jx/pull/62

    Full Changelog: https://github.com/go-faster/jx/compare/v0.38.0...v0.38.1

    Source code(tar.gz)
    Source code(zip)
  • v0.38.0(Jun 24, 2022)

    What's Changed

    • chore(deps): bump github.com/stretchr/testify from 1.7.4 to 1.7.5 by @dependabot in https://github.com/go-faster/jx/pull/60
    • fix: parse Num correctly by @tdakkota in https://github.com/go-faster/jx/pull/59

    Full Changelog: https://github.com/go-faster/jx/compare/v0.37.0...v0.38.0

    Source code(tar.gz)
    Source code(zip)
  • v0.37.0(Jun 21, 2022)

    What's Changed

    • test: ensure correct behaviour of Raw and Capture used together by @tdakkota in https://github.com/go-faster/jx/pull/54
    • feat: reduce streaming Raw memory usage by @tdakkota in https://github.com/go-faster/jx/pull/55
    • chore(deps): bump github.com/stretchr/testify from 1.7.2 to 1.7.4 by @dependabot in https://github.com/go-faster/jx/pull/56
    • fix: handling io.EOF error by @tdakkota in https://github.com/go-faster/jx/pull/57

    Full Changelog: https://github.com/go-faster/jx/compare/v0.36.0...v0.37.0

    Source code(tar.gz)
    Source code(zip)
  • v0.36.0(Jun 14, 2022)

    What's Changed

    • chore(deps): bump github.com/stretchr/testify from 1.7.1 to 1.7.2 by @dependabot in https://github.com/go-faster/jx/pull/52
    • feat: add Raw support for reader by @tdakkota in https://github.com/go-faster/jx/pull/53

    Full Changelog: https://github.com/go-faster/jx/compare/v0.35.2...v0.36.0

    Source code(tar.gz)
    Source code(zip)
  • v0.35.2(May 31, 2022)

    What's Changed

    • fix: support go1.17 by @ernado in https://github.com/go-faster/jx/pull/51

    Full Changelog: https://github.com/go-faster/jx/compare/v0.35.1...v0.35.2

    Source code(tar.gz)
    Source code(zip)
  • v0.35.1(May 29, 2022)

  • v0.35.0(May 16, 2022)

    What's Changed

    • chore(deps): bump github.com/segmentio/asm from 1.1.3 to 1.1.4 by @dependabot in https://github.com/go-faster/jx/pull/44
    • chore(deps): bump github.com/segmentio/asm from 1.1.4 to 1.1.5 by @dependabot in https://github.com/go-faster/jx/pull/45
    • chore(deps): bump github.com/segmentio/asm from 1.1.5 to 1.2.0 by @dependabot in https://github.com/go-faster/jx/pull/46
    • feat: add object iterator by @tdakkota in https://github.com/go-faster/jx/pull/48

    Full Changelog: https://github.com/go-faster/jx/compare/v0.34.0...v0.35.0

    Source code(tar.gz)
    Source code(zip)
  • v0.34.0(Apr 6, 2022)

    What's Changed

    • feat: add byte slice as JSON string writer by @tdakkota in https://github.com/go-faster/jx/pull/43

    Full Changelog: https://github.com/go-faster/jx/compare/v0.33.0...v0.34.0

    Source code(tar.gz)
    Source code(zip)
  • v0.33.0(Mar 26, 2022)

    What's Changed

    • test: add testcases from stdlib for float parser by @tdakkota in https://github.com/go-faster/jx/pull/37
    • feat: array iterator by @tdakkota in https://github.com/go-faster/jx/pull/33
    • chore(deps): bump github.com/stretchr/testify from 1.7.0 to 1.7.1 by @dependabot in https://github.com/go-faster/jx/pull/38
    • feat: reduce float decoding allocations by using unsafe by @tdakkota in https://github.com/go-faster/jx/pull/39
    • feat: use number set to speed up number parsing by @tdakkota in https://github.com/go-faster/jx/pull/40
    • feat: improve float decoding layout, add more float benchmarks by @tdakkota in https://github.com/go-faster/jx/pull/41
    • test: use integers.json file to benchmark integer decoder by @tdakkota in https://github.com/go-faster/jx/pull/42

    Full Changelog: https://github.com/go-faster/jx/compare/v0.32.2...v0.33.0

    Source code(tar.gz)
    Source code(zip)
  • v0.32.2(Feb 22, 2022)

    What's Changed

    • fix: do not unread, if next was failed by @tdakkota in https://github.com/go-faster/jx/pull/36

    Full Changelog: https://github.com/go-faster/jx/compare/v0.32.1...v0.32.2

    Source code(tar.gz)
    Source code(zip)
  • v0.32.1(Jan 25, 2022)

    What's Changed

    • fix: skip space if needed, when decoding bool/null by @tdakkota in https://github.com/go-faster/jx/pull/32

    Full Changelog: https://github.com/go-faster/jx/compare/v0.32.0...v0.32.1

    Source code(tar.gz)
    Source code(zip)
  • v0.32.0(Jan 21, 2022)

    What's Changed

    • fix: float decoding, improve coverage by @tdakkota in https://github.com/go-faster/jx/pull/25
    • feat: speed up escaped string decoding by @tdakkota in https://github.com/go-faster/jx/pull/28
    • feat: add Writer pool by @tdakkota in https://github.com/go-faster/jx/pull/31

    Full Changelog: https://github.com/go-faster/jx/compare/v0.31.0...v0.32.0

    Source code(tar.gz)
    Source code(zip)
  • v0.31.0(Jan 17, 2022)

    What's Changed

    • feat: unroll string decoder by @tdakkota in https://github.com/go-faster/jx/pull/23
    • test: add json corpus by @ernado in https://github.com/go-faster/jx/pull/24

    Full Changelog: https://github.com/go-faster/jx/compare/v0.30.0...v0.30.1

    Source code(tar.gz)
    Source code(zip)
  • v0.30.0(Jan 16, 2022)

    What's Changed

    • feat: unroll skipStr loop by @tdakkota in https://github.com/go-faster/jx/pull/22

    Full Changelog: https://github.com/go-faster/jx/compare/v0.29.0...v0.30.0

    Source code(tar.gz)
    Source code(zip)
  • v0.29.0(Jan 15, 2022)

    What's Changed

    • feat: inline read and match to consume by @tdakkota in https://github.com/go-faster/jx/pull/21

    Full Changelog: https://github.com/go-faster/jx/compare/v0.28.0...v0.29.0

    Source code(tar.gz)
    Source code(zip)
  • v0.28.0(Jan 14, 2022)

    What's Changed

    • feat: smarter object and array skip by @tdakkota in https://github.com/go-faster/jx/pull/19
    • feat: improve null and bool decoding by @tdakkota in https://github.com/go-faster/jx/pull/18

    Full Changelog: https://github.com/go-faster/jx/compare/v0.27.0...v0.28.0

    Source code(tar.gz)
    Source code(zip)
  • v0.27.0(Jan 13, 2022)

    What's Changed

    • test: cleanup some tests, add more testdata by @tdakkota in https://github.com/go-faster/jx/pull/15
    • feat: inline reading to consume by @tdakkota in https://github.com/go-faster/jx/pull/17
    • feat: smarter string skip by @tdakkota in https://github.com/go-faster/jx/pull/16

    Full Changelog: https://github.com/go-faster/jx/compare/v0.26.0...v0.27.0

    Source code(tar.gz)
    Source code(zip)
  • v0.26.0(Jan 13, 2022)

    What's Changed

    • feat: improve string encoding by @tdakkota in https://github.com/go-faster/jx/pull/9
    • feat: add writer by @ernado in https://github.com/go-faster/jx/pull/10
    • test(bench): use Writer in OTEL encode by @ernado in https://github.com/go-faster/jx/pull/11
    • feat(writer): improve base64 encoding by @ernado in https://github.com/go-faster/jx/pull/13
    • feat: rewrite skipNumber by @tdakkota in https://github.com/go-faster/jx/pull/12

    New Contributors

    • @ernado made their first contribution in https://github.com/go-faster/jx/pull/10

    Full Changelog: https://github.com/go-faster/jx/compare/v0.25.1...v0.26.0

    Source code(tar.gz)
    Source code(zip)
  • v0.26.0-alpha.0(Jan 12, 2022)

    What's Changed

    • feat: improve string encoding by @tdakkota in https://github.com/go-faster/jx/pull/9
    • feat: add writer by @ernado in https://github.com/go-faster/jx/pull/10

    New Contributors

    • @ernado made their first contribution in https://github.com/go-faster/jx/pull/10

    Full Changelog: https://github.com/go-faster/jx/compare/v0.25.1...v0.26.0-alpha.0

    Source code(tar.gz)
    Source code(zip)
  • v0.25.1(Jan 11, 2022)

    What's Changed

    • feat: improve BCE by @tdakkota in https://github.com/go-faster/jx/pull/7

    Full Changelog: https://github.com/go-faster/jx/compare/v0.25.0...v0.25.1

    Source code(tar.gz)
    Source code(zip)
  • v0.25.0(Nov 25, 2021)

    What's Changed

    • feat: generate integer encoders by @tdakkota in https://github.com/go-faster/jx/pull/6

    Full Changelog: https://github.com/go-faster/jx/compare/v0.24.0...v0.24.1

    Source code(tar.gz)
    Source code(zip)
  • v0.24.0(Nov 23, 2021)

    What's Changed

    • feat: add Capture support for readers by @tdakkota in https://github.com/go-faster/jx/pull/5

    New Contributors

    • @tdakkota made their first contribution in https://github.com/go-faster/jx/pull/5

    Full Changelog: https://github.com/go-faster/jx/compare/v0.23.3...v0.24.0

    Source code(tar.gz)
    Source code(zip)
  • v0.23.3(Nov 10, 2021)

  • v0.23.2(Nov 10, 2021)

  • v0.23.0(Nov 7, 2021)

  • v0.22.0(Nov 7, 2021)

Owner
go faster
causing performance
go faster
Fast JSON encoder/decoder compatible with encoding/json for Go

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

Masaaki Goshima 1.7k Aug 7, 2022
Golang JSON decoder supporting case-sensitive, number-preserving, and strict decoding use cases

Golang JSON decoder supporting case-sensitive, number-preserving, and strict decoding use cases

Kubernetes SIGs 12 Apr 3, 2022
A high-performance 100% compatible drop-in replacement of "encoding/json"

A high-performance 100% compatible drop-in replacement of "encoding/json" You can also use thrift like JSON using thrift-iterator Benchmark Source cod

Jsoniter 11.1k Aug 4, 2022
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

Samit Ghimire 7 Jul 29, 2022
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

null 4 Jul 18, 2022
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

Josh Baker 10.8k Aug 12, 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

William Poussier 179 Aug 4, 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

Aliaksandr Valialkin 1.6k Aug 4, 2022
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

William Poussier 129 Jul 10, 2022
/ˈdʏf/ - diff tool for YAML files, and sometimes JSON

dyff is inspired by the way the old BOSH v1 deployment output reported changes from one version to another by only showing the parts of a YAML file that change.

null 656 Aug 5, 2022
HuJSON: JSON for Humans (comments and trailing commas)

HuJSON - Human JSON The HuJSON decoder is a JSON decoder that also allows comments, both /* ... */ and // to end of line trailing commas on arrays and

Tailscale 406 Aug 9, 2022
tson is JSON viewer and editor written in Go

tson tson is JSON viewer and editor written in Go. This tool displays JSON as a tree and you can search and edit key or values. Support OS Mac Linux I

skanehira 129 Aug 8, 2022
JSONata in Go Package jsonata is a query and transformation language for JSON

JSONata in Go Package jsonata is a query and transformation language for JSON. It's a Go port of the JavaScript library JSONata.

Blues Inc 27 Jul 8, 2022
Slow and unreliable JSON parser generator (in progress)

VivaceJSON Fast and reliable JSON parser generator Todo List parse fields parse types generate struct generate (keypath+key) to struct Value Mapping F

null 7 Mar 3, 2022
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

Qntfy 205 Sep 17, 2021
Easy JSON parsing, stringifying, and accesing

Easy JSON parsing, stringifying, and accesing

Neutron 1 Nov 23, 2021
A tool to aggregate and mine data from JSON reports of Go tests.

teststat A tool to aggregate and mine data from JSON reports of Go tests. Why? Mature Go projects often have a lot of tests, and not all of them are i

Viacheslav Poturaev 3 Jul 20, 2022
Search and output the value of JSON by it's path.

Search and output the value of JSON by it's path.

Alexander Dawson 0 Dec 19, 2021
A simple GO module providing CRUD and match methods on a User "entity" stored locally as JSON

A simple GO module providing CRUD and match methods on a User "entity" stored locally as JSON. Created for GO language learning purposes. Once finishe

Lorenzo Piersante 0 Feb 5, 2022