forked from digisan/json-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dupfix_test.go
45 lines (41 loc) · 983 Bytes
/
dupfix_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package jsontool
import (
"os"
"strings"
"testing"
)
func TestDupFixOne(t *testing.T) {
fpath := "./data/out/la-Technologies"
AGAIN:
data, err := os.ReadFile(fpath + ".json")
if err != nil {
panic(err)
}
n := 30
prefix := "\n" + strings.Repeat(" ", n) + "\"asn_skillEmbodied\":"
jsx, ok := FixOneDupKeyOnce(string(data), prefix)
os.WriteFile(fpath+".json", []byte(jsx), os.ModePerm)
if !ok {
goto AGAIN
}
}
func TestFixOneDupKey(t *testing.T) {
fpath := "./data/dupkey"
data, err := os.ReadFile(fpath + ".json")
if err != nil {
panic(err)
}
n := 6
prefix := "\n" + strings.Repeat(" ", n) + "\"Age\":"
fixed := FixOneDupKey(string(data), prefix)
os.WriteFile(fpath+"1.json", []byte(fixed), os.ModePerm)
}
func TestRmDupEle(t *testing.T) {
fpath := "./data/dupele"
data, err := os.ReadFile(fpath + ".json")
if err != nil {
panic(err)
}
fixed := RmDupEle(string(data), "root.0.Age", nil)
os.WriteFile(fpath+"1.json", []byte(fixed), os.ModePerm)
}