如何获取cookie值

时间:2018-06-13 11:03:34

标签: javascript jquery

在页面上,cookie abc具有值

{"origin":"DEL","destination":"AMD","fromDate":"17 Jul 2018","toDate":"23 Jul 2018","multiCity":[],"promo":"","market":"","currencyCode":"INR","adults":1,"children":0,"infants":0,"journeyType":"roundTrip"}

我想获取journeyType值,我该如何获取值?

1 个答案:

答案 0 :(得分:0)

也许是这样的:



var cookie_str='{"origin":"DEL","destination":"AMD","fromDate":"17 Jul 2018","toDate":"23 Jul 2018","multiCity":[],"promo":"","market":"","currencyCode":"INR","adults":1,"children":0,"infants":0,"journeyType":"roundTrip"}';
var json_str=JSON.parse(cookie_str);
alert(json_str.journeyType);