I am a Software engineer who passionate about computer science / processor architecture / computer network
Currently working with Go Programming Language
Fastest JSON interpreter for GO
License: MIT License
Moving benchmarks to another branch can remove fake dependencies.
There must be a function to set or creates a key value pair if not exists.
example:
func SetValueIfNotNull(body []byte, key, value string) ([]byte, error) {
_, err := jin.Get(body, key)
if err != nil {
if err.Error() == jin.ErrKeyNotFound(key).Error() {
return jin.AddKeyValueString(body, key, value)
}
}
return jin.SetString(body, value, key)
}
AddKeyValueString is not adding quote to integer-convertable-string.
example:
var err error
b := jin.MakeEmptyJson()
b, err = jin.AddKeyValueString(b, "age", "3123")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(b))
outpput:
{"age":3123}
expecting:
{"age":"3123"}
Because I am adding value as "String".
In case of error some functions returning nil body.
// AddKeyValueString is a variation of AddKeyValue() func.
// Type of new value must be a string.
func AddKeyValueString(json []byte, key, value string, path ...string) ([]byte, error) {
if len(value) == 0 {
return nil, ErrNullNewValue()
}
if len(key) == 0 {
return nil, ErrNullKey()
}
return AddKeyValue(json, key, []byte(formatType(value)), path...)
}
known functions:
jin walk.go:45
current code:
default:
key := ""
if len(path) != 0 {
key = path[len(path)-1]
}
val, err := Get(json, path...)
if err != nil {
return err
}
callback(key, val, path) // return control is missing
}
must change with:
default:
key := ""
if len(path) != 0 {
key = path[len(path)-1]
}
val, err := Get(json, path...)
if err != nil {
return err
}
cont, err := callback(key, val, path)
if err != nil {
return err
}
if !cont {
return nil
}
}
Read File Error:read tests/node: is a directory
new public method for creating empty json object
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
github.com/ecoshub/jin.typeControlCore(0x14f9b68, 0x0, 0x0, 0xc000191aa0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/emreocak/go/pkg/mod/github.com/ecoshub/[email protected]/inter_type.go:134 +0x1f1
github.com/ecoshub/jin.GetType(0x14f9b68, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/emreocak/go/pkg/mod/github.com/ecoshub/[email protected]/inter_type.go:50 +0x98
setting a string field with null value is impossible.
example:
body := []byte(`{"name":"eco"}
_, err := jin.SetString(body, "", "name")
package main
import (
"fmt"
"github.com/ecoshub/jin"
)
func main() {
user := []byte(`{"name":"eco","age":30}`)
var err error
user, err = jin.Store(user, "gender", nil)
fmt.Println(err)
fmt.Println(string(user))
}
got:
<nil>
{"name":"eco","age":30,"gender":}
expected:
<nil>
{"name":"eco","age":30,"gender":null}
In JSON benchmark, which use 1.json sample, which is the best practice to parser/interpret x, y, z?
https://github.com/kostya/benchmarks
Jsoniter is faster than Jin on parser in this case.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.