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

Function parseObject

gjson.go:1196–1357  ·  view source on GitHub ↗
(c *parseContext, i int, path string)

Source from the content-addressed store, hash-verified

1194}
1195
1196func parseObject(c *parseContext, i int, path string) (int, bool) {
1197 var pmatch, kesc, vesc, ok, hit bool
1198 var key, val string
1199 rp := parseObjectPath(path)
1200 if !rp.more && rp.piped {
1201 c.pipe = rp.pipe
1202 c.piped = true
1203 }
1204 for i < len(c.json) {
1205 for ; i < len(c.json); i++ {
1206 if c.json[i] == '"' {
1207 // parse_key_string
1208 // this is slightly different from getting s string value
1209 // because we don't need the outer quotes.
1210 i++
1211 var s = i
1212 for ; i < len(c.json); i++ {
1213 if c.json[i] > '\\' {
1214 continue
1215 }
1216 if c.json[i] == '"' {
1217 i, key, kesc, ok = i+1, c.json[s:i], false, true
1218 goto parse_key_string_done
1219 }
1220 if c.json[i] == '\\' {
1221 i++
1222 for ; i < len(c.json); i++ {
1223 if c.json[i] > '\\' {
1224 continue
1225 }
1226 if c.json[i] == '"' {
1227 // look for an escaped slash
1228 if c.json[i-1] == '\\' {
1229 n := 0
1230 for j := i - 2; j > 0; j-- {
1231 if c.json[j] != '\\' {
1232 break
1233 }
1234 n++
1235 }
1236 if n%2 == 0 {
1237 continue
1238 }
1239 }
1240 i, key, kesc, ok = i+1, c.json[s:i], true, true
1241 goto parse_key_string_done
1242 }
1243 }
1244 break
1245 }
1246 }
1247 key, kesc, ok = c.json[s:], false, false
1248 parse_key_string_done:
1249 break
1250 }
1251 if c.json[i] == '}' {
1252 return i + 1, false
1253 }

Callers 2

parseArrayFunction · 0.85
GetFunction · 0.85

Calls 8

parseObjectPathFunction · 0.85
matchLimitFunction · 0.85
unescapeFunction · 0.85
parseStringFunction · 0.85
parseSquashFunction · 0.85
parseArrayFunction · 0.85
parseLiteralFunction · 0.85
parseNumberFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…