MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / jsonStringField

Function jsonStringField

internal/metadata/discover.go:266–288  ·  view source on GitHub ↗

jsonStringField does a tiny, dependency-free extraction of a top-level string field from a JSON object. Good enough for plugin.json name/description.

(content, field string)

Source from the content-addressed store, hash-verified

264// jsonStringField does a tiny, dependency-free extraction of a top-level string
265// field from a JSON object. Good enough for plugin.json name/description.
266func jsonStringField(content, field string) string {
267 needle := "\"" + field + "\""
268 idx := strings.Index(content, needle)
269 if idx < 0 {
270 return ""
271 }
272 rest := content[idx+len(needle):]
273 colon := strings.Index(rest, ":")
274 if colon < 0 {
275 return ""
276 }
277 rest = rest[colon+1:]
278 q1 := strings.Index(rest, "\"")
279 if q1 < 0 {
280 return ""
281 }
282 rest = rest[q1+1:]
283 q2 := strings.Index(rest, "\"")
284 if q2 < 0 {
285 return ""
286 }
287 return rest[:q2]
288}

Callers 1

parsePluginJSONFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected