You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working with a gNMI server which only supports JSON IETF encodings. So I am trying to convert the output of ygot diff API to JSON IETF Encodings:
type TypedValue struct {
// One of the fields within the val oneof is populated with the value
// of the update. The type of the value being included in the Update
// determines which field should be populated. In the case that the
// encoding is a particular form of the base protobuf type, a specific
// field is used to store the value (e.g., json_val).
//
// Types that are assignable to Value:
// *TypedValue_StringVal
// *TypedValue_IntVal
// *TypedValue_UintVal
// *TypedValue_BoolVal
// *TypedValue_BytesVal
// *TypedValue_FloatVal
// *TypedValue_DecimalVal
// *TypedValue_LeaflistVal
// *TypedValue_AnyVal
// *TypedValue_JsonVal
// *TypedValue_JsonIetfVal
// *TypedValue_AsciiVal
// *TypedValue_ProtoBytes
Value isTypedValue_Value protobuf_oneof:"value"
// contains filtered or unexported fields
}
Is there an API that gets TypedValue of different formats and converts them to JSON IETF?
Thanks,
The text was updated successfully, but these errors were encountered:
Unforunately I don't think there is a function that converts TypedValue to JSON, even if all of these are leafs.
One way is to unmarshal these one-by-one back into a GoStruct using ytypes' SetNode, and then getting each value via GetNode, and then calling ygot.Marshal7951.
Another way is to unmarshal all of them into a GoStruct using ytypes' SetNode, and then simply calling ygot.Marshal7951 that gives you a bigger piece of JSON.
Another way is to add to the implementation a new DiffOpt for ygot.Diff that encodes the values using Marshal7951 instead of EncodeTypedValue.
I am working with a gNMI server which only supports JSON IETF encodings. So I am trying to convert the output of ygot diff API to JSON IETF Encodings:
type TypedValue struct {
// One of the fields within the val oneof is populated with the value
// of the update. The type of the value being included in the Update
// determines which field should be populated. In the case that the
// encoding is a particular form of the base protobuf type, a specific
// field is used to store the value (e.g., json_val).
//
// Types that are assignable to Value:
// *TypedValue_StringVal
// *TypedValue_IntVal
// *TypedValue_UintVal
// *TypedValue_BoolVal
// *TypedValue_BytesVal
// *TypedValue_FloatVal
// *TypedValue_DecimalVal
// *TypedValue_LeaflistVal
// *TypedValue_AnyVal
// *TypedValue_JsonVal
// *TypedValue_JsonIetfVal
// *TypedValue_AsciiVal
// *TypedValue_ProtoBytes
Value isTypedValue_Value
protobuf_oneof:"value"
// contains filtered or unexported fields
}
Is there an API that gets TypedValue of different formats and converts them to JSON IETF?
Thanks,
The text was updated successfully, but these errors were encountered: