Skip to content

Syntax errors when parsing  #4

@flashingpumpkin

Description

@flashingpumpkin

Hi there.

I've come across errors when processing json from a couchdb. I'll use the standard _users database for example.

$ curl "localhost:5984/_users/_all_docs" 
{"total_rows":1,"offset":0,"rows":[
{"id":"_design/_auth","key":"_design/_auth","value":{"rev":"1-c44fb12a2676d481d235523092e0cec4"}}
]}

Now when sending through json, this is the output:

     $ curl "localhost:5984/_users/_all_docs" | json
 {
    "id": "_design/_auth",
    "key": "_design/_auth",
    "value": {
        "rev": "1-c44fb12a2676d481d235523092e0cec4"
    }
}

Here's the debugging output:

$ curl "localhost:5984/_users/_all_docs" | json -d
ex: {
    "stack": "SyntaxError: Unexpected end of input\n    at Object.parse (native)\n    at [object Object].processObjects (/usr/local/lib/node/.npm/json/0.0.8/package/lib/jsonCommand.js:351:31)\n    at Socket.<anonymous> (/usr/local/lib/node/.npm/json/0.0.8/package/lib/jsonCommand.js:443:40)\n    at Socket.emit (events.js:64:17)\n    at Socket._onReadable (net.js:667:31)\n    at IOWatcher.onReadable [as callback] (net.js:177:10)",
    "arguments": [],
    "type": "unexpected_eos",
    "message": "Unexpected end of input"
}
{
    "id": "_design/_auth",
    "key": "_design/_auth",
    "value": {
        "rev": "1-c44fb12a2676d481d235523092e0cec4"
    }
}
ex: {
    "stack": "SyntaxError: Unexpected token ]\n    at Object.parse (native)\n    at [object Object].processObjects (/usr/local/lib/node/.npm/json/0.0.8/package/lib/jsonCommand.js:351:31)\n    at Socket.<anonymous> (/usr/local/lib/node/.npm/json/0.0.8/package/lib/jsonCommand.js:448:18)\n    at Socket.emit (events.js:61:17)\n    at Socket._onReadable (net.js:652:51)\n    at IOWatcher.onReadable [as callback] (net.js:177:10)",
    "arguments": [
        "]"
    ],
    "type": "unexpected_token",
    "message": "Unexpected token ]"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions