Skip to content

Commit 35f7e06

Browse files
使用回官方的json解析器
1 parent 6492551 commit 35f7e06

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

jsondiff.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ func GetDiffNode(sourceJsonNode, patchJsonNode *decode.JsonNode, options ...Json
133133

134134
// AsDiffs 比较 patch 相比于 source 的差别,返回 json 格式的差异文档。
135135
func AsDiffs(source, patch []byte, options ...JsonDiffOption) ([]byte, error) {
136-
sourceJsonNode, err := decode.Unmarshal(source)
136+
// sourceJsonNode, err := decode.Unmarshal(source)
137+
sourceJsonNode, err := Unmarshal(source)
137138
if err != nil {
138139
return nil, errors.Wrap(err, "fail to unmarshal src")
139140
}
140-
patchJsonNode, err := decode.Unmarshal(patch)
141+
// patchJsonNode, err := decode.Unmarshal(patch)
142+
patchJsonNode, err := Unmarshal(patch)
141143
if err != nil {
142144
return nil, errors.Wrap(err, "fail to unmarshal tar")
143145
}
@@ -195,11 +197,13 @@ func merge(srcNode, diffNode *decode.JsonNode) error {
195197

196198
// MergeDiff 根据差异文档 diff 还原 source 的差异
197199
func MergeDiff(source, diff []byte) ([]byte, error) {
198-
diffNode, err := decode.Unmarshal(diff)
199-
if err != nil {
200+
// diffNode, err := decode.Unmarshal(diff)
201+
diffNode, err := Unmarshal(diff)
202+
if err != nil {
200203
return nil, errors.Wrap(err, "fail to unmarshal diff data")
201204
}
202-
srcNode, err := decode.Unmarshal(source)
205+
// srcNode, err := decode.Unmarshal(source)
206+
srcNode, err := Unmarshal(source)
203207
if err != nil {
204208
return nil, errors.Wrap(err, "fail to unmarshal source data")
205209
}

parse_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"fmt"
55
"github.com/520MianXiangDuiXiang520/json-diff/decode"
66
`io/ioutil`
7-
8-
// "io/ioutil"
97
"testing"
108
)
119

0 commit comments

Comments
 (0)