Skip to content

evorax/json-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-parser

under development...
this is json parser

Install

go get -u github.com/evorax/json-parser

example code

package main

import (
    "fmt"
    
    json "github.com/evorax/json-parser"
)

func main() {
	value := `{"str":"test","int":111,"bool":true,"null":null}`
	var result struct {
		Str  string `json:"str"`
		Int  int    `json:"int"`
		Bool bool   `json:"bool"`
		Null any    `json:"null"`
	}
	json.ParseJSON(value, &result)
	fmt.Println(result.Str)
	fmt.Println(result.Int)
	fmt.Println(result.Bool)
	fmt.Println(result.Null)
}

Benchmark

the difference is small, but here are the benchmark results

Benchmark Command is

go test -bench . -benchmem -v

Benchmark result is

Benchmark_Parser_Default-16     1000000000               0.0000224 ns/op
Benchmark_Parser-16             1000000000               0.0000196 ns/op