Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Safe stringify.

  • Loading branch information...
commit fcf6d6765247a2645a233d95468ade2960294074 1 parent 8feb957
@mikeal mikeal authored
Showing with 5 additions and 3 deletions.
  1. +3 −2 index.js
  2. +2 −1  package.json
View
5 index.js
@@ -27,6 +27,7 @@ var http = require('http')
, uuid = require('node-uuid')
, mime = require('mime')
, tunnel = require('tunnel-agent')
+ , safeStringify = require('json-stringify-safe')
, ForeverAgent = require('forever-agent')
, FormData = require('form-data')
@@ -914,11 +915,11 @@ Request.prototype.json = function (val) {
if (typeof val === 'boolean') {
if (typeof this.body === 'object') {
this.setHeader('content-type', 'application/json')
- this.body = JSON.stringify(this.body)
+ this.body = safeStringify(this.body)
}
} else {
this.setHeader('content-type', 'application/json')
- this.body = JSON.stringify(val)
+ this.body = safeStringify(val)
}
return this
}
View
3  package.json
@@ -29,7 +29,8 @@
"aws-sign": "~0.2.0",
"oauth-sign": "~0.2.0",
"forever-agent": "~0.2.0",
- "tunnel-agent": "~0.2.0"
+ "tunnel-agent": "~0.2.0",
+ "json-stringify-safe": "~3.0.0"
},
"scripts": {
"test": "node tests/run.js"
Please sign in to comment.
Something went wrong with that request. Please try again.