kennethreitz/httpbin — Issue #30: Retuned JSON data is not valid JSON
Author: vlucas
Created: 2012-02-06 22:33:00+00:00
State: open

The following [Frisby](http://frisbyjs.com) test demonstrates this best:

var frisby = require('frisby');

frisby.create('Ensure response has proper JSON types in specified keys')
.post('http://httpbin.org/post', {
arr: [1, 2, 3, 4],
foo: "bar",
bar: "baz",
answer: 42
}, {json: true})
.expectJSON('data', {
arr: Array,
foo: String,
bar: String,
answer: Number
})
.inspectBody()
.toss()

Returned response is:

{ origin: '127.0.0.1',
files: {},
form: {},
headers:
{ 'Content-Length': '53',
'X-Forwarded-Port': '80',
Connection: 'keep-alive',
Host: 'httpbin.org',
Cookie: '',
'Content-Type': 'application/json' },
url: 'http://httpbin.org/post',
args: {},
data: '{"arr":[1,2,3,4],"foo":"bar","bar":"baz","answer":42}' }

Which renders the "data" key in a way that can't be run through JSON.parse() in node.js. This should be returned in full JSON glory instead of packed in a string.