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
Support JSON stringify replacer argument. #2009
Conversation
Updated to remove extra semicolon. |
@mikeal Anything I can do to move this one forward? It seems like a simple change and complements the existing use of the reviver when parsing JSON, but I haven't heard a yeah, a nay or a please-change-this from anyone. |
So, I'm +1 on adding this for now but it should be named something else, like "jsonStringify". |
Thanks @mikeal. Just to explain my reasoning, I went with That said, if you're sure that something like |
Possibly something like |
Test failures appear unrelated... |
@@ -749,6 +749,7 @@ The first argument can be either a `url` or an `options` object. The only requir | |||
- `postambleCRLF` - append a newline/CRLF at the end of the boundary of your `multipart/form-data` request. | |||
- `json` - sets `body` to JSON representation of value and adds `Content-type: application/json` header. Additionally, parses the response body as JSON. | |||
- `jsonReviver` - a [reviver function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) that will be passed to `JSON.parse()` when parsing a JSON response body. | |||
- `jsonReplacer` - a [replacer function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) that will be passed to `JSON.string()` when stringifying a JSON request body. |
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.
The function is called JSON.stringify()
not JSON.string()
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.
Ta, fixed. Got it right in the URL, not sure what I was thinking in the comment.
Adds support for the replacer argument of JSON.stringify, in the same way that request already supports the revivier argument for JSON.parse. Change jsonReplacer arg to jsonStringifier. Revert "Change jsonReplacer arg to jsonStringifier." This reverts commit 40c03af.
Apologies on the squashing, I can probably reconstruct it out of the reflog if you'd like to see it how it was. The only change in the last one was to correct the |
Ok 👍 do you want this change published soon? It's probably a good time for new release anyway. |
Thanks for the merge, whenever suits you to release is fine by me. On Sat, 26 Mar 2016 18:50 simo notifications@github.com wrote:
|
Adds support for the replacer argument of JSON.stringify, in the same
way that request already supports the revivier argument for JSON.parse.