Skip to content

Commit 39b6cb5

Browse files
Codelaxquantumsheep
authored andcommitted
feat(args): handle JSONObject args
1 parent aac6365 commit 39b6cb5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/args/unmarshal.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ var unmarshalFuncs = map[reflect.Type]UnmarshalFunc{
9999
*(dest.(*time.Duration)) = duration
100100
return nil
101101
},
102+
reflect.TypeOf((*scw.JSONObject)(nil)).Elem(): func(value string, dest interface{}) error {
103+
jsonObject, err := scw.DecodeJSONObject(value, scw.NoEscape)
104+
if err != nil {
105+
return fmt.Errorf("failed to parse json object: %w", err)
106+
}
107+
*(dest.(*scw.JSONObject)) = jsonObject
108+
return nil
109+
},
102110
}
103111

104112
// UnmarshalStruct parses args like ["arg1=1", "arg2=2"] to a Go structure using reflection.

0 commit comments

Comments
 (0)