MCPcopy Create free account
hub / github.com/cel-expr/cel-go / yamlEncodeValue

Function yamlEncodeValue

ext/encoders.go:995–1012  ·  view source on GitHub ↗
(val ref.Val)

Source from the content-addressed store, hash-verified

993}
994
995func yamlEncodeValue(val ref.Val) (string, error) {
996 jsonStr, err := jsonEncodeValue(val)
997 if err != nil {
998 return "", err
999 }
1000 dec := json.NewDecoder(strings.NewReader(jsonStr))
1001 dec.UseNumber()
1002 var obj any
1003 if err := dec.Decode(&obj); err != nil {
1004 return "", err
1005 }
1006 cleaned := normalizeJSONNumber(obj)
1007 yamlBytes, err := yaml.Marshal(cleaned)
1008 if err != nil {
1009 return "", err
1010 }
1011 return string(yamlBytes), nil
1012}
1013
1014func yamlToJSON(str string) (string, bool) {
1015 trimmed := strings.TrimSpace(str)

Callers 2

CompileOptionsMethod · 0.85
YAMLEncodeFunction · 0.85

Calls 2

jsonEncodeValueFunction · 0.85
normalizeJSONNumberFunction · 0.85

Tested by

no test coverage detected