简体   繁体   中英

How do I decode this JSON string containing Magento product options?

Magento stores product options in an encoded string as shown below. I am trying to figure out how to turn it into a usable object. I have tried eval('(' + below + ')') without success. It throws an undefined error:

undefined:1 nY3VzdG9tcHJpbnR ^

this is the sting I'm trying to parse:

 a:2:{s:15:"info_buyRequest";a:6:{s:4:"uenc";s:80:"aHR0cDovL2NnY3VzdG9tcHJpbnRpbmcuY29tLzE2eDI0LXByZW1pdW0tZ2FsbGVyeS13cmFwLmh0bWw,";s:7:"product";s:2:"12";s:15:"related_product";s:0:"";s:7:"options";a:2:{i:19;s:2:"16";i:18;a:9:{s:4:"type";s:24:"application/octet-stream";s:5:"title";s:16:"16x24 canvas.jpg";s:10:"quote_path";s:64:"/media/custom_options/quote/57cb4f796670cb680511f6fca1055a9f.jpg";s:10:"order_path";s:64:"/media/custom_options/order/57cb4f796670cb680511f6fca1055a9f.jpg";s:8:"fullpath";s:128:"/mnt/stor13-wc2-dfw1/480123/www.internetswebsite.com/web/content/media/custom_options/quote/57cb4f796670cb680511f6fca1055a9f.jpg";s:4:"size";s:7:"4692319";s:5:"width";i:4050;s:6:"height";i:2850;s:10:"secret_key";s:20:"ee79b5a12bfe9fc6c350";}}s:15:"options_18_file";s:83:"http://internetswebsite.com/media/tmp/uploader/57cb4f796670cb680511f6fca1055a9f.jpg";s:3:"qty";s:1:"1";}s:7:"options";a:2:{i:0;a:7:{s:5:"label";s:11:"Orientation";s:5:"value";s:22:"Landscape (Horizontal)";s:11:"print_value";s:22:"Landscape (Horizontal)";s:9:"option_id";s:2:"19";s:11:"option_type";s:5:"radio";s:12:"option_value";s:2:"16";s:11:"custom_view";b:0;}i:1;a:7:{s:5:"label";s:17:"Upload your photo";s:5:"value";s:162:"<a href="https://internetswebsite.com/sales/download/downloadCustomOption/id/35461/key/ee79b5a12bfe9fc6c350/" target="_blank">16x24 canvas.jpg</a> 4050 x 2850 px.";s:11:"print_value";s:32:"16x24 canvas.jpg 4050 x 2850 px.";s:9:"option_id";s:2:"18";s:11:"option_type";s:4:"file";s:12:"option_value";s:677:"a:10:{s:4:"type";s:24:"application/octet-stream";s:5:"title";s:16:"16x24 canvas.jpg";s:10:"quote_path";s:64:"/media/custom_options/quote/57cb4f796670cb680511f6fca1055a9f.jpg";s:10:"order_path";s:64:"/media/custom_options/order/57cb4f796670cb680511f6fca1055a9f.jpg";s:8:"fullpath";s:128:"/mnt/stor13-wc2-dfw1/480123/www.internetswebsite.com/web/content/media/custom_options/quote/57cb4f796670cb680511f6fca1055a9f.jpg";s:4:"size";s:7:"4692319";s:5:"width";i:4050;s:6:"height";i:2850;s:10:"secret_key";s:20:"ee79b5a12bfe9fc6c350";s:3:"url";a:2:{s:5:"route";s:35:"sales/download/downloadCustomOption";s:6:"params";a:2:{s:2:"id";s:5:"35461";s:3:"key";s:20:"ee79b5a12bfe9fc6c350";}}}";s:11:"custom_view";b:1;}}}

Any idea how to go about this in javascript?

可能是您应该使用php :-)(反序列化)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM