File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,6 +67,25 @@ func (exp *responseExpectation) JsonBody(object interface{}) ResponseExpectation
6767 return exp .Body (nil )
6868 }
6969
70+ switch t := object .(type ) {
71+ case []byte :
72+ var object interface {}
73+ err := json .Unmarshal (t , & object )
74+ if err != nil {
75+ exp .t .Fatalf ("response expectation failed: could not parse to json: %+v" , object )
76+ }
77+ resData , _ := json .Marshal (object )
78+ return exp .Body (resData )
79+ case string :
80+ var object interface {}
81+ err := json .Unmarshal ([]byte (t ), & object )
82+ if err != nil {
83+ exp .t .Fatalf ("response expectation failed: could not parse to json: %+v" , object )
84+ }
85+ resData , _ := json .Marshal (object )
86+ return exp .Body (resData )
87+ }
88+
7089 jsonBody , err := json .Marshal (object )
7190 if err != nil {
7291 exp .t .Fatalf ("response expectation failed: could not parse to json: %+v" , object )
You can’t perform that action at this time.
0 commit comments