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

Function jsonEncodeNativeStruct

ext/encoders.go:525–543  ·  view source on GitHub ↗
(nativeVal any)

Source from the content-addressed store, hash-verified

523}
524
525func jsonEncodeNativeStruct(nativeVal any) (string, bool) {
526 if nativeVal == nil {
527 return "", false
528 }
529 if _, isProto := nativeVal.(proto.Message); isProto {
530 return "", false
531 }
532 rt := reflect.TypeOf(nativeVal)
533 if rt.Kind() == reflect.Pointer {
534 rt = rt.Elem()
535 }
536 if rt.Kind() == reflect.Struct {
537 jsonBytes, err := json.Marshal(nativeVal)
538 if err == nil {
539 return string(jsonBytes), true
540 }
541 }
542 return "", false
543}
544
545func jsonEncodeList(lister traits.Lister) (string, error) {
546 szVal := lister.Size()

Callers 2

jsonEncodeValueFunction · 0.85

Calls 1

KindMethod · 0.65

Tested by 1