0

I have created a hash in java script and passing it to controller through Ajax request but in controller i'm getting hash in string

{1100:{time:\"1\", mark:\"1\", difficulty_level:\"3\"}, 1108:{time:\"1\", mark:\"1\", difficulty_level:\"3\"}}

I have tried using JSON.parse but getting error JSON::ParserError: 710: unexpected token at

1
  • 3
    It's not json, it's a js object. Check your JSON here: jsonlint.com Commented Nov 26, 2012 at 9:55

1 Answer 1

2

You should find a way to create a proper JSON from your JavaScript object, by using some JavaScript library (such as JSON-js), and JSON.stringify(myObject) . JSON requires all string-values (keys and values alike) to be surrounded by quotation marks.

So in your case, the proper JSON would look like this (non-quote escaped):

{1100:{"time":"1", "mark": "1", "difficulty_level": "3"}, 1108:{ "time":"1", "mark":"1", "difficulty_level": "3"}}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.