json

package module
v0.0.0-...-0f5a841 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 6 Imported by: 0

README

jsonimp

Overview

Provide a json module that has a encoding/json compatible interface that allows you to use a more optimal json on backend such as go-json, sonic, etc

Supported Backends

  encoding/json Sonic go-json
Default on AMD64 no yes no
Default on ARM64 yes no no
AMD64 Support yes yes yes
ARM64 Support yes no yes
MarshalIndent yes runtime yes

Example

On amd64 systems, this code will automatically use Sonic to parse JSON.

package main

import (
  "fmt"
  json "github.com/nibbleshift/jsonimp"
)

func main() {

  a, err := json.Marshal([]string{"foo", "bar", "baz"})

  if err != nil {
    fmt.Println(err)
    return
   }
   fmt.Println(string(a))
}

TODO

  • Add feature flag for sonic
  • Add feature flag for go-json
  • Add feature flag for encoding/json
  • Add default for amd64 (sonic)
  • Add default for arm64 (go-json)
  • Add additional usage documentation
  • Implement generic tests for all available json implementations.
  • Implement benchmarks for all available json implementations.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NewDecoder    = newDecoder
	NewEncoder    = newEncoder
	Marshal       = sonic.Marshal
	Unmarshal     = sonic.Unmarshal
	MarshalIndent = runtimejson.MarshalIndent
)

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	*decoder.Decoder
}

type Encoder

type Encoder struct {
	*encoder.StreamEncoder
}

type Number

type Number string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL