Skip to content

Add support for marshalling/unmarshalling JSON#6969

Merged
jhendrixMSFT merged 2 commits intoAzure:masterfrom
jhendrixMSFT:azcore_json
Jan 16, 2020
Merged

Add support for marshalling/unmarshalling JSON#6969
jhendrixMSFT merged 2 commits intoAzure:masterfrom
jhendrixMSFT:azcore_json

Conversation

@jhendrixMSFT
Copy link
Copy Markdown
Member

Removed Response.Payload field, replacing it with an internal
implementation nopClosingBytesReader.

Removed Response.Payload field, replacing it with an internal
implementation nopClosingBytesReader.
// TODO: verify early exit is correct
if len(r.payload()) == 0 {
return newRequestError("missing payload", r)
return nil
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question, to understand the reason behind returning nil, wouldn't it be better to return an error is the payload empty? Since clearly calling the function means that there was the expectation that something would be unmarshaled?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my original assumption, however the byte_getNull test expects this to be valid. I actually think the swagger is malformed, i.e. the MIME type should be application/text and not application/json as none of the models are actually JSON. We also have this same behavior in track 1, but again it might be predicated on some bad assumptions (i.e. is there ever a valid success case where the swagger specifies a JSON model but the service is allowed to return null).

Copy link
Copy Markdown
Member

@catalinaperalta catalinaperalta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just left a question to understand the error handling we're going to use for UnmarshalAsJSON

@jhendrixMSFT jhendrixMSFT merged commit dfc6a17 into Azure:master Jan 16, 2020
@jhendrixMSFT jhendrixMSFT deleted the azcore_json branch January 16, 2020 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants