//Creating a 2-d Json array
var JSONObject = {
"name": "John Johnson",
"street": "Oslo West 16",
"age": 33,
"phone": "555 1234567"
};
var JSONObject1 = {
"movie": "zindagi",
"wedding": "yes"
};
var cookieval = {
"akamai" + ':' + JSONObject,
"sV" + ':' + JSONObject1
}
$.cookie('test', cookieval); // creating a cookie with a Json value
readJson('test', 'sV');
function readJSON(name, param) {
var cookievalue = $.cookie('test');
var parJson = $.parseJSON(cookievalue);
var strmovie = parJson.sV;
//Should return me JSOn object of sV and this works but when i try the following it does not.
var strmovie = parJson+'.'+param;
// Because param is a string and not Json, var strMovie returns an undefined value.
// How do i get the value of json dynamically
}
質問する
80 次