0

i want to get amount value from following json response how to get

Object {readyState: 4, responseText: "{"amount":1231,"firstName":"dfsdf","lastName":"lasernmae","email":"[email protected]"}", status: 200, statusText: "OK"}

 complete: function(response) 
					{
						
						
						var jsonObject = $.parseJSON(response);
						console.debug(jsonObject.responseText.amount);
				

					}

for above coding i am getting Uncaught SyntaxError: Unexpected token o.

2 Answers 2

1

DEMO1

var data = '{"readyState": 4, "responseText": {"amount":1231,"firstName":"dfsdf","lastName":"lasernmae","email":"[email protected]"}, "status": 200, "statusText": "OK"}';
var jsonObject = $.parseJSON(data);
console.debug(jsonObject.responseText.amount);

if you have responseText as String you can use following code:

DEMO2

var resT = $.parseJSON(response.responseText);
console.debug(resT.amount);
Sign up to request clarification or add additional context in comments.

4 Comments

Uncaught SyntaxError: Unexpected token o.
jsfiddle.net/dipali_vasani/jtgspddu/1 check this. if you are getting response same as this, there should not be a problem.
but here i am getting double quotes before curly braces for responseText.
@vijaikarthik : check updated answer. you will get your solution
1

Assuming your object has the variable name of data. Just do..

var amount = data.responseText.amount;

If you are getting that response from a server, and still need to parse it.

var data = JSON.parse(theObjectsVariableNameHere);
var amount = data.responseText.amount;

1 Comment

getting error VM8211:1 Uncaught SyntaxError: Unexpected token o

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.