0

I having a JSON value which returns from the server. I can.t Parse this value. Find the below JSON value

{"Result":{"d8bf6ab7-21a2-4964-a2cf-e7a1db097f08_FROM":"FROM"}}

If i try to get the value like

console.log(Result.d8bf6ab7-21a2-4964-a2cf-e7a1db097f08_FROM);
console.log(Result[d8bf6ab7-21a2-4964-a2cf-e7a1db097f08_FROM]);

It throws error

SyntaxError: identifier starts immediately after numeric literal
2

1 Answer 1

1

Try this:

var obj = {"Result":{"d8bf6ab7-21a2-4964-a2cf-e7a1db097f08_FROM":"FROM"}};

console.log(obj.Result["d8bf6ab7-21a2-4964-a2cf-e7a1db097f08_FROM"]);
Sign up to request clarification or add additional context in comments.

3 Comments

It works, can you explain why i cant use . operator to get the value??? like obj.Result.***
You can't get it because you have hyphens which are considered as minus signs.
Read this Property Name Guidelines and you will understand. If my answer is correct, then accept it so that it will be useful for others.

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.