MCPcopy Create free account
hub / github.com/diillson/chatcli / decodeFieldsObject

Function decodeFieldsObject

cli/plugins/builtin_memory.go:385–399  ·  view source on GitHub ↗

decodeFieldsObject reads a JSON object from raw, accepting the direct object form and the JSON-encoded string the agent flattener produces when it stringifies a nested object into a "--fields" argv value.

(raw json.RawMessage)

Source from the content-addressed store, hash-verified

383// object form and the JSON-encoded string the agent flattener produces when
384// it stringifies a nested object into a "--fields" argv value.
385func decodeFieldsObject(raw json.RawMessage) map[string]interface{} {
386 var direct map[string]interface{}
387 if err := json.Unmarshal(raw, &direct); err == nil {
388 return direct
389 }
390 var s string
391 if err := json.Unmarshal(raw, &s); err != nil {
392 return nil
393 }
394 var inner map[string]interface{}
395 if err := json.Unmarshal([]byte(s), &inner); err != nil {
396 return nil
397 }
398 return inner
399}
400
401// stringifyMap coerces JSON values to strings (numbers/bools become text;
402// arrays are joined with commas so list fields round-trip).

Callers 1

parseProfileFieldsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected