@ -75,31 +75,31 @@ func (i RawItem) String() string {
return fmt . Sprintf ( "%v%s" , i . data . Value . Value , suffix )
}
// MarshalJSON V2 implements [jsonv2.MarshalerV2 ].
func ( i RawItem ) MarshalJSON V2 ( out * jsontext . Encoder , opts jsonv2 . Options ) error {
return jsonv2 . MarshalEncode ( out , & i . data , opts )
// MarshalJSON To implements [jsonv2.MarshalerTo ].
func ( i RawItem ) MarshalJSON To ( out * jsontext . Encoder ) error {
return jsonv2 . MarshalEncode ( out , & i . data )
}
// UnmarshalJSON V2 implements [jsonv2.UnmarshalerV2 ].
func ( i * RawItem ) UnmarshalJSON V2 ( in * jsontext . Decoder , opts jsonv2 . Options ) error {
return jsonv2 . UnmarshalDecode ( in , & i . data , opts )
// UnmarshalJSON From implements [jsonv2.UnmarshalerFrom ].
func ( i * RawItem ) UnmarshalJSON From ( in * jsontext . Decoder ) error {
return jsonv2 . UnmarshalDecode ( in , & i . data )
}
// MarshalJSON implements [json.Marshaler].
func ( i RawItem ) MarshalJSON ( ) ( [ ] byte , error ) {
return jsonv2 . Marshal ( i ) // uses MarshalJSON V2
return jsonv2 . Marshal ( i ) // uses MarshalJSON To
}
// UnmarshalJSON implements [json.Unmarshaler].
func ( i * RawItem ) UnmarshalJSON ( b [ ] byte ) error {
return jsonv2 . Unmarshal ( b , i ) // uses UnmarshalJSON V2
return jsonv2 . Unmarshal ( b , i ) // uses UnmarshalJSON From
}
// RawValue represents a raw policy setting value read from a policy store.
// It is JSON-marshallable and facilitates unmarshalling of JSON values
// into corresponding policy setting types, with special handling for JSON numbers
// (unmarshalled as float64) and JSON string arrays (unmarshalled as []string).
// See also [RawValue.UnmarshalJSON V2 ].
// See also [RawValue.UnmarshalJSON From ].
type RawValue struct {
opt . Value [ any ]
}
@ -114,16 +114,16 @@ func RawValueOf[T RawValueType](v T) RawValue {
return RawValue { opt . ValueOf [ any ] ( v ) }
}
// MarshalJSON V2 implements [jsonv2.MarshalerV2 ].
func ( v RawValue ) MarshalJSON V2 ( out * jsontext . Encoder , opts jsonv2 . Options ) error {
return jsonv2 . MarshalEncode ( out , v . Value , opts )
// MarshalJSON To implements [jsonv2.MarshalerTo ].
func ( v RawValue ) MarshalJSON To ( out * jsontext . Encoder ) error {
return jsonv2 . MarshalEncode ( out , v . Value )
}
// UnmarshalJSON V2 implements [jsonv2.UnmarshalerV2 ] by attempting to unmarshal
// UnmarshalJSON From implements [jsonv2.UnmarshalerFrom ] by attempting to unmarshal
// a JSON value as one of the supported policy setting value types (bool, string, uint64, or []string),
// based on the JSON value type. It fails if the JSON value is an object, if it's a JSON number that
// cannot be represented as a uint64, or if a JSON array contains anything other than strings.
func ( v * RawValue ) UnmarshalJSON V2 ( in * jsontext . Decoder , opts jsonv2 . Options ) error {
func ( v * RawValue ) UnmarshalJSON From ( in * jsontext . Decoder ) error {
var valPtr any
switch k := in . PeekKind ( ) ; k {
case 't' , 'f' :
@ -139,7 +139,7 @@ func (v *RawValue) UnmarshalJSONV2(in *jsontext.Decoder, opts jsonv2.Options) er
default :
panic ( "unreachable" )
}
if err := jsonv2 . UnmarshalDecode ( in , valPtr , opts ); err != nil {
if err := jsonv2 . UnmarshalDecode ( in , valPtr ); err != nil {
v . Value . Clear ( )
return err
}
@ -150,12 +150,12 @@ func (v *RawValue) UnmarshalJSONV2(in *jsontext.Decoder, opts jsonv2.Options) er
// MarshalJSON implements [json.Marshaler].
func ( v RawValue ) MarshalJSON ( ) ( [ ] byte , error ) {
return jsonv2 . Marshal ( v ) // uses MarshalJSON V2
return jsonv2 . Marshal ( v ) // uses MarshalJSON To
}
// UnmarshalJSON implements [json.Unmarshaler].
func ( v * RawValue ) UnmarshalJSON ( b [ ] byte ) error {
return jsonv2 . Unmarshal ( b , v ) // uses UnmarshalJSON V2
return jsonv2 . Unmarshal ( b , v ) // uses UnmarshalJSON From
}
// RawValues is a map of keyed setting values that can be read from a JSON.