优化自动生成json #3

Merged
zhangdeman merged 24 commits from feature/tree into master 2023-05-05 16:10:39 +08:00
2 changed files with 11 additions and 1 deletions
9bbd781a1f key解析支持转义符的处理
白茶清欢
2023-03-30 12:02:40 +08:00
Commit 10 of 24
Show all commits

No files matched your search

+10
View File
@@ -108,6 +108,16 @@ func (g *Generate) getKey(startIndex int) (string, int, error) {
startIndex++
break
}
if charStr == KeywordEscapeSymbol {
// 转义符
startIndex++
if startIndex >= len(g.jsonDataByte) {
// 转义符后面没东西了
return "", startIndex, errors.New("escape symbol without any data")
}
charStr = string(g.jsonDataByte[startIndex])
}
keyCharList = append(keyCharList, charStr)
startIndex++
}
+1 -1
View File
@@ -13,7 +13,7 @@ import (
)
func TestNew(t *testing.T) {
jsonData := `{"name": "zhang", "age":17}`
jsonData := `{"n\\\\\\ame": "zhang", "age":17}`
g, err := New(jsonData)
if nil != err {
fmt.Println(err.Error())
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.