-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for parsing json response #32
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -447,6 +447,12 @@ | |
} catch (e) { | ||
// Unable to parse XML - no biggie | ||
} | ||
} else if(this.responseText && /(application\/json)|(application\/vnd\.api\+json)/.test(type)) { | ||
try { | ||
this.response = JSON.parse(this.responseText); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't correct in terms of the spec. There is always a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nlfurniss thanks, yes we should be careful to not deviate from the spec. Could you briefly describe the implications of this violation? I suspect you have a use-case in-mind, and rather then guessing what the use-case is, knowing it will help the rest of us think about this correctly. I likely have some follow up questions. Also, do you see a path forward for the PR, or does your concern invalidate it entirely? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My use-case is JSON, but it seemed like this semi-completeness might confuse people. After looking at it again, I don't think it's a blocker but I'll create an issue after it lands setting out that |
||
} catch (e) { | ||
// Unable to parse JSON - no biggie | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets only catch errors related to parse failure. That we we don't swallow unexpected errors |
||
} | ||
} | ||
|
||
if (this.async) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -441,6 +441,12 @@ var FakeXMLHttpRequestProto = { | |
} catch (e) { | ||
// Unable to parse XML - no biggie | ||
} | ||
} else if(this.responseText && /(application\/json)|(application\/vnd\.api\+json)/.test(type)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space between |
||
try { | ||
this.response = JSON.parse(this.responseText); | ||
} catch (e) { | ||
// Unable to parse JSON - no biggie | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ |
||
} | ||
} | ||
|
||
if (this.async) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between
if
and(