Sorry if this is repost but I couldn't find my question after I posted it. I have a rails app that is rendering a json string and storing the same sting in the db. The output from the initial page that receives the output and the page that displays the data from the db have different output. The data and the function to format the data are identical. I'm stumped.
function:
function prettyPrint(jsonStr) {
var jsonObj = jQuery.parseJSON(jsonStr);
return '<pre>' + JSON.stringify(jsonObj,null,'\t') + '</pre>';
}
data:
{"Account":{"account_id":1},"response_details":[],"return_code":200,"Devices":[{"imei":"1234","name":"Device 1"},{"imei":"54321","name":"device 3"},{"imei":"354476024650842","name":"device 4 [no data]"},{"imei":"55124","name":"BlackBerry (8800)"},{"imei":"1234567890","name":"Garmin Sample"},{"imei":"987654321","name":"Second Garmin"},{"imei":"546787545678","name":"Tower 1"}]}
output 1: (from ajax)
{
"Account": {
"account_id": 1
},
"response_details": [],
"return_code": 200,
"Devices": [
{
"imei": "1234",
"name": "Device 1"
},
{
"imei": "54321",
"name": "device 3"
},
{
"imei": "354476024650842",
"name": "device 4 [no data]"
},
{
"imei": "55124",
"name": "BlackBerry (8800)"
},
{
"imei": "1234567890",
"name": "Garmin Sample"
},
{
"imei": "987654321",
"name": "Second Garmin"
},
{
"imei": "546787545678",
"name": "Tower 1"
}
]
}
output 2: (from db)
{
"Account": {
"account_id": 1
},
"response_details": "[]",
"return_code": 200,
"Devices": "[{\"imei\": \"1234\", \"name\": \"Device 1\"}, {\"imei\": \"54321\", \"name\": \"device 3\"}, {\"imei\": \"354476024650842\", \"name\": \"device 4 [no data]\"}, {\"imei\": \"55124\", \"name\": \"BlackBerry (8800)\"}, {\"imei\": \"1234567890\", \"name\": \"Garmin Sample\"}, {\"imei\": \"987654321\", \"name\": \"Second Garmin\"}, {\"imei\": \"546787545678\", \"name\": \"Tower 1\"}]"
}