如何解码包含Magento产品选项的JSON字符串?

时间:2012-02-16 10:17:23

标签: javascript json magento

Magento将产品选项存储在编码字符串中,如下所示。我试图弄清楚如何将它变成一个可用的对象。我已经尝试了eval('('+ below +')')但没有成功。它抛出一个未定义的错误:

  

未定义:1   nY3VzdG9tcHJpbnR   ^

这是我试图解析的刺痛:

 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;}}}

任何想法如何在javascript中进行此操作?

1 个答案:

答案 0 :(得分:3)

可能你应该使用php :-)(unserialize)