-3

On page the cookies abc has value

{"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"}

I want to fetch journeyType value, how should I get the value ?

Ambika Tewari
  • 251
  • 3
  • 9

1 Answers1

0

Maybe like this:

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);
mscdeveloper
  • 2,749
  • 1
  • 10
  • 17