Socket
Socket
Sign inDemoInstall

github.com/json-iterator/go

Package Overview
Dependencies
5
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/json-iterator/go

Package jsoniter implements encoding and decoding of JSON as defined in RFC 4627 and provides interfaces with identical syntax of standard lib encoding/json. Converting from encoding/json to jsoniter is no more than replacing the package with jsoniter and variable type declarations (if any). jsoniter interfaces gives 100% compatibility with code using standard lib. "JSON and Go" (https://golang.org/doc/articles/json_and_go.html) gives a description of how Marshal/Unmarshal operate between arbitrary or predefined json objects and bytes, and it applies to jsoniter.Marshal/Unmarshal as well. Besides, jsoniter.Iterator provides a different set of interfaces iterating given bytes/string/reader and yielding parsed elements one by one. This set of interfaces reads input as required and gives better performance.


Version published

Readme

Source

Sourcegraph GoDoc Build Status codecov rcard License Gitter chat

A high-performance 100% compatible drop-in replacement of "encoding/json"

Benchmark

benchmark

Source code: https://github.com/json-iterator/go-benchmark/blob/master/src/github.com/json-iterator/go-benchmark/benchmark_medium_payload_test.go

Raw Result (easyjson requires static code generation)

ns/opallocation bytesallocation times
std decode35510 ns/op1960 B/op99 allocs/op
easyjson decode8499 ns/op160 B/op4 allocs/op
jsoniter decode5623 ns/op160 B/op3 allocs/op
std encode2213 ns/op712 B/op5 allocs/op
easyjson encode883 ns/op576 B/op3 allocs/op
jsoniter encode837 ns/op384 B/op4 allocs/op

Always benchmark with your own workload. The result depends heavily on the data input.

Usage

100% compatibility with standard lib

Replace

import "encoding/json"
json.Marshal(&data)

with

import jsoniter "github.com/json-iterator/go"

var json = jsoniter.ConfigCompatibleWithStandardLibrary
json.Marshal(&data)

Replace

import "encoding/json"
json.Unmarshal(input, &data)

with

import jsoniter "github.com/json-iterator/go"

var json = jsoniter.ConfigCompatibleWithStandardLibrary
json.Unmarshal(input, &data)

More documentation

How to get

go get github.com/json-iterator/go

Contribution Welcomed !

Contributors

Report issue or pull request, or email taowen@gmail.com, or Gitter chat

FAQs

Last updated on 11 Sep 2021

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc