user1023465 user1023465 - 3 months ago 4x
JSON Question

How do I access an element of this JSON object created by JSON.parse?

I am using an AJAX POST to send a JSON object from the client side my server. However, I'm a little confused as to how to access the object once it gets there.

Here's my POST from the client side:

var data = JSON.stringify({
'app': 'reviews',
'name': '',
'review': '',
'response': '',
'rating': rating,
'url': url,
'date': date
type: "POST",
url: "",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
failure: function(errMsg) {

This works just fine. On my server, I print the body of the request and it looks fine:


Then I call JSON.parse on it, and everything still works as I expected, here is the result:


This is saved in a variable called post. However, when I try to access or post['app'], I get an undefined. Can anybody let me know where I'm going wrong?


This very same issue happened to me when I mistakenly used JSON.stringify on an object that was already a string, which it looks is exactly what you are doing.