(val ref.Val)
| 137 | } |
| 138 | |
| 139 | func jsonEncodeValue(val ref.Val) (string, error) { |
| 140 | native, err := val.ConvertToNative(types.JSONValueType) |
| 141 | if err != nil { |
| 142 | return "", err |
| 143 | } |
| 144 | jsonValue, ok := native.(*structpb.Value) |
| 145 | if !ok { |
| 146 | return "", fmt.Errorf("cannot convert %T to JSON value", native) |
| 147 | } |
| 148 | jsonBytes, err := protojson.Marshal(jsonValue) |
| 149 | if err != nil { |
| 150 | return "", err |
| 151 | } |
| 152 | return string(jsonBytes), nil |
| 153 | } |
no test coverage detected