valueToJSON converts the CEL type to a protobuf JSON representation and marshals the result to a string.
(val ref.Val)
| 513 | // valueToJSON converts the CEL type to a protobuf JSON representation and |
| 514 | // marshals the result to a string. |
| 515 | func valueToJSON(val ref.Val) string { |
| 516 | v, err := val.ConvertToNative(reflect.TypeOf(&structpb.Value{})) |
| 517 | if err != nil { |
| 518 | glog.Exit(err) |
| 519 | } |
| 520 | marshaller := protojson.MarshalOptions{Indent: " "} |
| 521 | bytes, err := marshaller.Marshal(v.(proto.Message)) |
| 522 | if err != nil { |
| 523 | glog.Exit(err) |
| 524 | } |
| 525 | return string(bytes) |
| 526 | } |
| 527 | |
| 528 | var ( |
| 529 | emptyClaims = make(map[string]string) |
no test coverage detected