Journey JSON in node.js


I'm playing around with Journey on node and I only realized that the router is interpreting JSON requests objects as the value of the key that has an empty value:

In other words, when i post to the server a JSON object I get the following:> post /events
... {url : "test"}
HTTP/1.1 200 OK
Date: Tue, 21 Feb 2012 00:42:38 GMT
Server: journey/0.4.0
Content-Type: application/json;charset=utf-8
Content-Length: 67
Connection: keep-alive

    event: {
        _id: '10tPxx',
        resource: 'Event',
        {url : "test"}: ''

As you can see the whole object is being considered as a string.

Here's my Journey related code:

exports.createRouter = function(resource){
    var router = new (journey.Router)({
        api: 'basic'
    router.path(/\/events/, function(){
...., event){
            resource.create(event, function(err, result){
                    return res.send(500, {}, {error: err.error});
                res.send(200, {}, { event: result});
    return router;

The printout of the console is:

{ '{url : "test"}': '' }

What could possibly be wrong?

Problem courtesy of: mabounassif


It looks like the json is getting parsed using querystring.parse instead of JSON.parse.

Make sure that you are properly sending a 'content-type' header with 'application/json'.

Solution courtesy of: loganfsmyth


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.