0

I am sending this json to express app and getting parsing error:

{
  "first_name" : "User",
  "last_name" : "one",
  "country" : "IN",
  "dob" : "1980-04-11",
  "email": "userone@gmail.com",
  "password": "abcd12345",
  "username": "usernameone"
}

The error is:

SyntaxError: Unexpected string
at Object.parse (native)
at IncomingMessage.<anonymous> (/Users/saransh2012/Developer/vypics/node_modules/express/node_modules/connect/lib/middleware/json.js:76:27)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at _stream_readable.js:910:16
at process._tickCallback (node.js:415:13)

I think the error is in the date thing, what am I doing wrong?? Please help.

Saransh Mohapatra
  • 9,062
  • 10
  • 35
  • 49
  • `SyntaxError: Unexpected string`: Just a guess, but is it possible that you are passing a JSON string to a function that expects it to have been parsed already? – Dan Ross Jun 30 '13 at 20:33
  • There is nothing wrong with the actual JSON that you have posted, I even ran it through [JSONLint](http://jsonlint.com/). – Dan Ross Jun 30 '13 at 20:34
  • [This](http://stackoverflow.com/questions/16879598/invalid-json-get-request-express-js#answer-16886712) answer might be relevant if the JSON is being sent to the server by a GET request as url parameters. – Dan Ross Jun 30 '13 at 20:40
  • 1
    No Its a post request. But I got the problem sorted out. It was an error in parsing from server side. It was getting parsed twice so I was getting the error – Saransh Mohapatra Jul 01 '13 at 07:21
  • Can you tell how are you posting the JSON. Show the code to sent the JSON. – user568109 Jul 01 '13 at 07:21

0 Answers0