Skip to content

Commit

Permalink
使用回官方的json解析器
Browse files Browse the repository at this point in the history
  • Loading branch information
520MianXiangDuiXiang520 committed Aug 21, 2021
1 parent 6492551 commit 35f7e06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 9 additions & 5 deletions jsondiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,13 @@ func GetDiffNode(sourceJsonNode, patchJsonNode *decode.JsonNode, options ...Json

// AsDiffs 比较 patch 相比于 source 的差别,返回 json 格式的差异文档。
func AsDiffs(source, patch []byte, options ...JsonDiffOption) ([]byte, error) {
sourceJsonNode, err := decode.Unmarshal(source)
// sourceJsonNode, err := decode.Unmarshal(source)
sourceJsonNode, err := Unmarshal(source)
if err != nil {
return nil, errors.Wrap(err, "fail to unmarshal src")
}
patchJsonNode, err := decode.Unmarshal(patch)
// patchJsonNode, err := decode.Unmarshal(patch)
patchJsonNode, err := Unmarshal(patch)
if err != nil {
return nil, errors.Wrap(err, "fail to unmarshal tar")
}
Expand Down Expand Up @@ -195,11 +197,13 @@ func merge(srcNode, diffNode *decode.JsonNode) error {

// MergeDiff 根据差异文档 diff 还原 source 的差异
func MergeDiff(source, diff []byte) ([]byte, error) {
diffNode, err := decode.Unmarshal(diff)
if err != nil {
// diffNode, err := decode.Unmarshal(diff)
diffNode, err := Unmarshal(diff)
if err != nil {
return nil, errors.Wrap(err, "fail to unmarshal diff data")
}
srcNode, err := decode.Unmarshal(source)
// srcNode, err := decode.Unmarshal(source)
srcNode, err := Unmarshal(source)
if err != nil {
return nil, errors.Wrap(err, "fail to unmarshal source data")
}
Expand Down
2 changes: 0 additions & 2 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"github.com/520MianXiangDuiXiang520/json-diff/decode"
`io/ioutil`

// "io/ioutil"
"testing"
)

Expand Down

0 comments on commit 35f7e06

Please sign in to comment.