1 Star 1 Fork 0

DiDi-opensource/gojsondiff

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
unmarshaler_test.go 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
Iwasaki Yudai 提交于 2016-08-12 13:21 . Add Makefile and wercker.yml
package gojsondiff_test
import (
. "github.com/yudai/gojsondiff"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/yudai/gojsondiff/tests"
"encoding/json"
"fmt"
"github.com/yudai/pp"
)
var _ = Describe("Gojsondiff", func() {
Describe("Unmarshaller", func() {
Describe("CompareObjects", func() {
It("", func() {
um := NewUnmarshaller()
diff, err := um.UnmarshalString(`
{
"summary": [
"@@ -638,17 +638,17 @@\n via, Bra\n-z\n+s\n il, %0ACh\n@@ -916,20 +916,13 @@\n re a\n-lso known as\n+.k.a.\n Car\n",
0,
2
],
"surface": [
17840000,
0,
0
],
"demographics": {
"population": [
385742554,
385744896
]
},
"languages": {
"2": [
"inglés"
],
"_t": "a",
"_2": [
"english",
0,
0
]
},
"countries": {
"0": {
"capital": [
"Buenos Aires",
"Rawson"
]
},
"9": [
{
"name": "Antártida",
"unasur": false
}
],
"10": {
"population": [
42888594
]
},
"_t": "a",
"_4": [
"",
10,
3
],
"_8": [
"",
2,
3
],
"_10": [
{
"name": "Uruguay",
"capital": "Montevideo",
"independence": "1825-08-25T07:00:00.000Z",
"unasur": true
},
0,
0
],
"_11": [
{
"name": "Venezuela",
"capital": "Caracas",
"independence": "1811-07-05T07:00:00.000Z",
"unasur": true
},
0,
0
]
},
"spanishName": [
"Sudamérica"
]
}
`)
Expect(err).To(BeNil())
pp.Print(diff)
a := LoadFixture("FIXTURES/jsondiffpatch.json")
differ := New()
differ.ApplyPatch(a, diff)
pp.Println(a)
result, _ := json.Marshal(a)
fmt.Println(string(result))
})
})
})
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/didiopensource/gojsondiff.git
git@gitee.com:didiopensource/gojsondiff.git
didiopensource
gojsondiff
gojsondiff
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385