eval(JSON)Vs eval('('+ JSON')')之间的区别是什么?

时间:2011-07-25 06:33:05

标签: javascript json eval

  

可能重复:
  Why the open quote and bracket for eval('(' + jsonString+ ')') when parsing json string

var JSON = {
    "offers": [
        {
            "targetURL": "http://www.whotels.com/playinplansmobile?language=en_US",
            "title": "WHO PUTS THE PLAY IN YOUR PLANS?",
            "stayStartDate": "Feb 08, 2010",
            "stayEndDate": "Dec 31, 2011",
            "offerName": "WHO PUTS THE PLAY IN YOUR PLANS?",
            "expirationDate": "Dec 22, 2011",
            "htmlLongDesc": " <p>Getaway with a hot W Hotels escape. Your W Hotels Play experience includes two cool cocktails, daily parking, and a Wonderful Room youll love at a wow-worthy rate! Book now for Play dates all year long, through December 22, 2011.</p>",
            "effectiveDate": "Feb 07, 2010",
            "offerCode": "WPLAY",
            "businessValue": "90",
            "propIds": "1114,1153,1154,1234,1299,1300,1433,1471,1521,1522,1599,1736,1785,1788,1789,2005,2030,3019,3131,3154,3167,3224,97502,97508,97509,97518",
            "media": "/en_US/Media/Graphics/Brands/W/Images/specialOffers/Opening_Offer_LP_Austin_03224_final.jpg"
        },
        {
            "targetURL": "http://www.starwoodpromos.com/bettertomorrows50/?IM=SPG_7792944SS_4P_MX_NAD&language=en_US&language=en_US",
            "title": "Save 40% off on your next night.",
            "stayStartDate": "Jan 14, 2009",
            "stayEndDate": "Dec 30, 2011",
            "offerName": "Save 40% off on your next night.",
            "expirationDate": "Dec 30, 2011",
            "htmlLongDesc": " <p>Better tomorrows are on us.  For every night you stay at our regular rate, you get the next night at 40% off, now through December 31, 2010.</p>",
            "effectiveDate": "Jan 13, 2009",
            "offerCode": "bettertomorrowsmobile",
            "businessValue": "80",
            "propIds": "123,208,212,213,217,304,364,639,645,653,661,671,712,742,744,749,752,761,778,786,817,818,822,849,856,862,879,913,917,930,949,990,1126,1141,1142,1151,1156,1165,1168,1180,1203,1223,1237,1243,1256,1257,1260,1263,1270,1329,1355,1357,1387,1408,1473,1476,1481,1490,1504,1515,1538,1544,1548,1561,1567,1580,1587,1592,1712,1730,1731,1748,1758,1775,1980,1989,1994,3038,3040,3061,3063,3064,3109,3122,3194,97506",
            "media": "/en_US/Media/Graphics/Brands/W/Images/specialOffers/MB_bettertomorrowsmobile.jpg"
        }
    ]
}

以上是我试图转换为对象的JSON字符串。当我使用eval(JSON)时,它正确地转换为Object,但是当我使用eval('('+ JSON +')')时,它会在元素列表之后抛出“missing”。我试图了解两者之间的区别。

0 个答案:

没有答案