MCPcopy
hub / github.com/tidwall/gjson / parseObjectPath

Function parseObjectPath

gjson.go:982–1048  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

980}
981
982func parseObjectPath(path string) (r objectPathResult) {
983 for i := 0; i < len(path); i++ {
984 if path[i] == '|' {
985 r.part = path[:i]
986 r.pipe = path[i+1:]
987 r.piped = true
988 return
989 }
990 if path[i] == '.' {
991 r.part = path[:i]
992 if i < len(path)-1 && isDotPiperChar(path[i+1:]) {
993 r.pipe = path[i+1:]
994 r.piped = true
995 } else {
996 r.path = path[i+1:]
997 r.more = true
998 }
999 return
1000 }
1001 if path[i] == '*' || path[i] == '?' {
1002 r.wild = true
1003 continue
1004 }
1005 if path[i] == '\\' {
1006 // go into escape mode. this is a slower path that
1007 // strips off the escape character from the part.
1008 epart := []byte(path[:i])
1009 i++
1010 if i < len(path) {
1011 epart = append(epart, path[i])
1012 i++
1013 for ; i < len(path); i++ {
1014 if path[i] == '\\' {
1015 i++
1016 if i < len(path) {
1017 epart = append(epart, path[i])
1018 }
1019 continue
1020 } else if path[i] == '.' {
1021 r.part = string(epart)
1022 if i < len(path)-1 && isDotPiperChar(path[i+1:]) {
1023 r.pipe = path[i+1:]
1024 r.piped = true
1025 } else {
1026 r.path = path[i+1:]
1027 r.more = true
1028 }
1029 return
1030 } else if path[i] == '|' {
1031 r.part = string(epart)
1032 r.pipe = path[i+1:]
1033 r.piped = true
1034 return
1035 } else if path[i] == '*' || path[i] == '?' {
1036 r.wild = true
1037 }
1038 epart = append(epart, path[i])
1039 }

Callers 1

parseObjectFunction · 0.85

Calls 1

isDotPiperCharFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…