Skip to content

Commit 9f09c3a

Browse files
committed
🚚 rename xjson
1 parent cfbca51 commit 9f09c3a

15 files changed

+35
-40
lines changed

README.md

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,35 @@
1-
<p align="center">
2-
<img
3-
src="gjson-logo.PNG"
4-
width="300" height="270" border="0" alt="GJSON">
5-
<br>
61

72

83

94
</p>
105
<p align="center">
11-
<a href="https://goreportcard.com/report/github.com/crossoverJie/gjson"><img src="https://goreportcard.com/badge/github.com/crossoverJie/gjson"></a>
12-
<a href="https://codecov.io/gh/crossoverJie/gjson"><img src="https://codecov.io/gh/crossoverJie/gjson/branch/main/graph/badge.svg?token=51WIOVFN95"></a>
6+
<a href="https://goreportcard.com/report/github.com/crossoverJie/xjson"><img src="https://goreportcard.com/badge/github.com/crossoverJie/xjson"></a>
7+
<a href="https://codecov.io/gh/crossoverJie/xjson"><img src="https://codecov.io/gh/crossoverJie/xjson/branch/main/graph/badge.svg?token=51WIOVFN95"></a>
138
<br>
149
Query and Arithmetic
1510
</p>
1611

1712

18-
`gjson` is a `JSON` parsing library, you can query `JSON` like `OOP`.
13+
`xjson` is a `JSON` parsing library, you can query `JSON` like `OOP`.
1914

2015
```go
2116
str := `{"people":{"name":{"first":"bob"}}}`
22-
first := gjson.Get(str, "people.name.first")
17+
first := xjson.Get(str, "people.name.first")
2318
assert.Equal(t, first.String(), "bob")
2419
```
2520

2621
Even perform arithmetic operations with `JSON`.
2722

2823
```go
2924
str := `{"people":[{"bob":{"age":10}},{"alice":{"age":10}}]}`
30-
age := gjson.GetWithArithmetic(str, "people[0].bob.age + people[1].alice.age")
25+
age := xjson.GetWithArithmetic(str, "people[0].bob.age + people[1].alice.age")
3126
assert.Equal(t, age.Int(), 20)
3227
```
3328

3429
Installing:
3530

3631
```shell
37-
go get github.com/crossoverJie/gjson
32+
go get github.com/crossoverJie/xjson
3833
```
3934

4035
# Query Syntax
@@ -63,35 +58,35 @@ str := `
6358
}
6459
}`
6560

66-
name := gjson.Get(str, "name")
61+
name := xjson.Get(str, "name")
6762
assert.Equal(t, name.String(), "bob")
6863

69-
age := gjson.Get(str, "age")
64+
age := xjson.Get(str, "age")
7065
assert.Equal(t, age.Int(), 20)
7166

72-
assert.Equal(t, gjson.Get(str,"skill.lang[0].go.feature[0]").String(), "goroutine")
73-
assert.Equal(t, gjson.Get(str,"skill.lang[0].go.feature[1]").String(), "channel")
74-
assert.Equal(t, gjson.Get(str,"skill.lang[0].go.feature[2]").String(), "simple")
75-
assert.Equal(t, gjson.Get(str,"skill.lang[0].go.feature[3]").Bool(), true)
67+
assert.Equal(t, xjson.Get(str,"skill.lang[0].go.feature[0]").String(), "goroutine")
68+
assert.Equal(t, xjson.Get(str,"skill.lang[0].go.feature[1]").String(), "channel")
69+
assert.Equal(t, xjson.Get(str,"skill.lang[0].go.feature[2]").String(), "simple")
70+
assert.Equal(t, xjson.Get(str,"skill.lang[0].go.feature[3]").Bool(), true)
7671
```
7772

7873
The tow syntax work together to obtain complex nested `JSON` data.
7974

8075
# Arithmetic Syntax
8176

82-
`gjson` supports `+ - * / ()` arithmetic operations.
77+
`xjson` supports `+ - * / ()` arithmetic operations.
8378

8479
```go
8580
str := `{"name":"bob", "age":10,"magic":10.1, "score":{"math":[1,2]}}`
86-
result := gjson.GetWithArithmetic(str, "(age+age)*age+magic")
81+
result := xjson.GetWithArithmetic(str, "(age+age)*age+magic")
8782
assert.Equal(t, result.Float(), 210.1)
88-
result = gjson.GetWithArithmetic(str, "(age+age)*age")
83+
result = xjson.GetWithArithmetic(str, "(age+age)*age")
8984
assert.Equal(t, result.Int(), 200)
9085

91-
result = gjson.GetWithArithmetic(str, "(age+age) * age + score.math[0]")
86+
result = xjson.GetWithArithmetic(str, "(age+age) * age + score.math[0]")
9287
assert.Equal(t, result.Int(), 201)
9388

94-
result = gjson.GetWithArithmetic(str, "(age+age) * age - score.math[0]")
89+
result = xjson.GetWithArithmetic(str, "(age+age) * age - score.math[0]")
9590
assert.Equal(t, result.Int(), 199)
9691
```
9792

@@ -152,7 +147,7 @@ func TestJson(t *testing.T) {
152147
}
153148
}
154149
}`
155-
decode, err := gjson.Decode(str)
150+
decode, err := xjson.Decode(str)
156151
assert.Nil(t, err)
157152
fmt.Println(decode)
158153
v := decode.(map[string]interface{})
@@ -181,8 +176,8 @@ func TestJson(t *testing.T) {
181176
```
182177

183178
# Features
184-
- [x] Support syntax: `gjson.Get("glossary.title")`
185-
- [x] Support arithmetic operators: `gjson.Get("glossary.age+long")`
179+
- [x] Support syntax: `xjson.Get("glossary.title")`
180+
- [x] Support arithmetic operators: `xjson.Get("glossary.age+long")`
186181
- [ ] Resolve to struct
187182

188183
# Acknowledgements

arithmetic_token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gjson
1+
package xjson
22

33
type ArithmeticToken string
44

arithmetic_token_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gjson
1+
package xjson
22

33
import (
44
"fmt"

benckmark/benchmark_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package benckmark
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/crossoverJie/gjson"
6+
"github.com/crossoverJie/xjson"
77
"github.com/stretchr/testify/assert"
88
"testing"
99
)
@@ -141,12 +141,12 @@ func BenchmarkJsonDecode(b *testing.B) {
141141
func BenchmarkDecode(b *testing.B) {
142142
b.ReportAllocs()
143143
for i := 0; i < b.N; i++ {
144-
gjson.Decode(str)
144+
xjson.Decode(str)
145145
}
146146
}
147147

148148
func TestBig(t *testing.T) {
149-
decode, err := gjson.Decode(str)
149+
decode, err := xjson.Decode(str)
150150
assert.Nil(t, err)
151151
fmt.Println(decode)
152152
}

gjson-logo.PNG

-56.5 KB
Binary file not shown.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/crossoverJie/gjson
1+
module github.com/crossoverJie/xjson
22

33
go 1.16
44

grammar_token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gjson
1+
package xjson
22

33
import "errors"
44

grammar_token_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gjson
1+
package xjson
22

33
import (
44
"fmt"

json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gjson
1+
package xjson
22

33
import (
44
"fmt"

json_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gjson
1+
package xjson
22

33
import (
44
"encoding/json"

json_token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gjson
1+
package xjson
22

33
import "errors"
44

json_token_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gjson
1+
package xjson
22

33
import (
44
"fmt"

parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gjson
1+
package xjson
22

33
import (
44
"errors"

stack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gjson
1+
package xjson
22

33
import "fmt"
44

stack_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package gjson
1+
package xjson
22

33
import (
44
"github.com/stretchr/testify/assert"

0 commit comments

Comments
 (0)