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

Function jsonBool

cli/plugins/builtin_context.go:596–615  ·  view source on GitHub ↗

jsonBool reads a boolean field, tolerating "true"/"1" strings.

(raw map[string]json.RawMessage, keys ...string)

Source from the content-addressed store, hash-verified

594
595// jsonBool reads a boolean field, tolerating "true"/"1" strings.
596func jsonBool(raw map[string]json.RawMessage, keys ...string) bool {
597 for _, k := range keys {
598 v, ok := raw[k]
599 if !ok {
600 continue
601 }
602 var b bool
603 if err := json.Unmarshal(v, &b); err == nil {
604 return b
605 }
606 var s string
607 if err := json.Unmarshal(v, &s); err == nil {
608 switch strings.ToLower(strings.TrimSpace(s)) {
609 case "true", "1", "yes", "on":
610 return true
611 }
612 }
613 }
614 return false
615}

Callers 1

ExecuteWithStreamMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected