Skip to content

itchyny/sonnet

 
 

Repository files navigation

Sonnet

gopher.jpeg

High performance JSON decoder in Go

Features

  • 100% compatible with the Go standard library.

  • Efficient. uses less memory and roughly 5 times faster than the standard library when decoding JSON.

  • Decent streaming (io.Reader) support.

Motivation

  • Why another JSON decoder?

I was amazed at the number of JSON packages, but I guess i was more surprised when I realized the problems they had. I'll mention that in the next section. In short... they were incompatible, and slow. That's when I decided to create this.

Problems we had

  • CPU dependent

Use of assembly; drops support for things like M1/raspberry pi, since they have different architectures

  • Not user friendly

Complicated and (or) Incompatible APIs - making the migration difficult.

  • Preparation

A switch-case needs to be written by the user, or a static code generation needs to be used.

  • Not actively maintained

Newer versions are often unsupported. they sometimes have EOL packages as dependencies

  • Not so fast at the end

Lots of reflections, poor streaming (io.Reader) features

Installation

go get github.com/sugawarayuuta/sonnet

Usage

The usage is the same as the standard library.

Use pkg.go.dev website, or read the blog post

Benchmarks

Medium Payload
medium.png
Small Payload Large Payload
small.png large.png

Thanks

About

High performance JSON decoder in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%