{"issue":{"created_at":"2011-12-09T01:20:43Z","state":"closed","updated_at":"2011-12-09T05:27:25Z","comments":6,"user":{"gravatar_id":"31597e9be6abe8ff0130e8bbb051a28a","id":427337,"url":"https://api.github.com/users/beatgammit","avatar_url":"https://secure.gravatar.com/avatar/31597e9be6abe8ff0130e8bbb051a28a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"beatgammit"},"body":"I am using connect 1.8.2, and when I POST a string without surrounding quotes, the client receives a huge error string.\r\n\r\nThis doesn't really seem like the intent, which was probably to send a JSON string, surrounded with double-quotes. IMHO, if a JSON.parse fails, it should set body to be the string value instead of spitting out an error.\r\n\r\nTherefore, these requests should have an identical result:\r\n\r\n`curl -X POST localhost:5000/ -d 'hello' -H 'Content-Type: application/json'`\r\n\r\n`curl -X POST localhost:5000/ -d '\"hello\"' -H 'Content-Type: application/json'`\r\n\r\nI can see how this would not be ideal for everyone (especially those who want to catch errors or depend on receiving a JSON object instead of a string), so bodyParser could either accept a param that tells it to ignore parse errors and just give the string, or there could be a simple regex to see if an input string is just a unquoted JSON string, something like this:\r\n\r\n    try {\r\n        req.body = JSON.parse(str);\r\n        fn();\r\n    } catch (err) {\r\n        if (!/^\\s*[{\\]]/.test(str)) {\r\n            req.body = str;\r\n            fn();\r\n            return;\r\n        }\r\n        fn(err);\r\n    }","assignee":null,"id":2497430,"labels":[],"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":434,"title":"bodyParser suggestion with json parsing","closed_at":"2011-12-09T05:27:25Z","html_url":"https://github.com/senchalabs/connect/issues/434","url":"https://api.github.com/repos/senchalabs/connect/issues/434","milestone":null},"action":"created","comment":{"created_at":"2011-12-09T05:27:25Z","updated_at":"2011-12-09T05:27:25Z","user":{"gravatar_id":"31597e9be6abe8ff0130e8bbb051a28a","id":427337,"url":"https://api.github.com/users/beatgammit","avatar_url":"https://secure.gravatar.com/avatar/31597e9be6abe8ff0130e8bbb051a28a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"beatgammit"},"body":"Alright, I guess that is good enough. I'll go ahead and close this since it seems to be a won't fix.","id":3075680,"url":"https://api.github.com/repos/senchalabs/connect/issues/comments/3075680"}}