From 8824625ea8dfeb1848f1ce23374c83006bbffa3a Mon Sep 17 00:00:00 2001 From: "Richard T. Carback III" <rick.carback@gmail.com> Date: Tue, 5 Jul 2022 19:40:37 +0000 Subject: [PATCH] Remove the Parse functions and replace them with Marshaller helpers --- xxdk/params.go | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/xxdk/params.go b/xxdk/params.go index f2e85770b..10621cade 100644 --- a/xxdk/params.go +++ b/xxdk/params.go @@ -54,17 +54,14 @@ func GetDefaultCMixParams() CMIXParams { } } -// ParseCMixParameters returns the default Params, or override with given -// parameters, if set. -func ParseCMixParameters(cmixParamsJSON string) (CMIXParams, error) { - p := GetDefaultCMixParams() - if len(cmixParamsJSON) > 0 { - err := json.Unmarshal([]byte(cmixParamsJSON), &p) - if err != nil { - return CMIXParams{}, err - } - } - return p, nil +// Unmarshal fills an empty object with the deserialized contents of jsonData +func (p *CMIXParams) Unmarshal(jsonData []byte) error { + return json.Unmarshal(jsonData, p) +} + +// Marshal creates json data of the object +func (p *CMIXParams) Marshal() ([]byte, error) { + return json.Marshal(p) } //////////////////////////////////////// @@ -81,15 +78,12 @@ func GetDefaultE2EParams() E2EParams { } } -// GetParameters returns the default Params, or override with given -// parameters, if set. -func ParseE2EParameters(e2eParamsJSON string) (E2EParams, error) { - p := GetDefaultE2EParams() - if len(e2eParamsJSON) > 0 { - err := json.Unmarshal([]byte(e2eParamsJSON), &p) - if err != nil { - return E2EParams{}, err - } - } - return p, nil +// Unmarshal fills an empty object with the deserialized contents of jsonData +func (p *E2EParams) Unmarshal(jsonData []byte) error { + return json.Unmarshal(jsonData, p) +} + +// Marshal creates json data of the object +func (p *E2EParams) Marshal() ([]byte, error) { + return json.Marshal(p) } -- GitLab