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

Function stringifyMap

cli/plugins/builtin_memory.go:403–422  ·  view source on GitHub ↗

stringifyMap coerces JSON values to strings (numbers/bools become text; arrays are joined with commas so list fields round-trip).

(in map[string]interface{})

Source from the content-addressed store, hash-verified

401// stringifyMap coerces JSON values to strings (numbers/bools become text;
402// arrays are joined with commas so list fields round-trip).
403func stringifyMap(in map[string]interface{}) map[string]string {
404 out := make(map[string]string, len(in))
405 for k, v := range in {
406 switch val := v.(type) {
407 case string:
408 out[k] = val
409 case []interface{}:
410 parts := make([]string, 0, len(val))
411 for _, item := range val {
412 parts = append(parts, fmt.Sprintf("%v", item))
413 }
414 out[k] = strings.Join(parts, ", ")
415 case nil:
416 // skip
417 default:
418 out[k] = fmt.Sprintf("%v", val)
419 }
420 }
421 return out
422}
423
424// memoryFlagsToJSON converts ["--key","value",...] into a JSON object.
425func memoryFlagsToJSON(argv []string) (string, error) {

Callers 2

TestStringifyMapFunction · 0.85
parseProfileFieldsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestStringifyMapFunction · 0.68