add parse functons with io reader
This commit is contained in:
@@ -2,6 +2,7 @@ package tecaminodbmjson_data
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
||||
"github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
@@ -10,10 +11,14 @@ func NewResponse() *models.Response {
|
||||
return &models.Response{}
|
||||
}
|
||||
|
||||
func ParseResponse(b []byte) (*models.Response, error) {
|
||||
func ParseResponse(body io.ReadCloser) (*models.Response, error) {
|
||||
b, err := io.ReadAll(body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r := models.Response{}
|
||||
|
||||
err := json.Unmarshal(b, &r)
|
||||
err = json.Unmarshal(b, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user