4

可能重复:
JSON Javascript 转义

我在 jsonlint 上测试了我的 JSON,它是有效的,但是当我尝试解析它时出现错误,

这是我的 JSON 和要解析的函数:

var listVideo = JSON.parse('[{"blobkey":"AMIfv94kAyQziQMwOLOrjqBK-MxqQqeBK96dS4Fh5DgR-yIW4jHq3luUwNvGpTOfUD9qXlFNQUjYXGkYrmmV8_mrZKbiK6MAUJwuSQkhxw-qaQZLVHcpb19gWUEpxiAzh1z4fMyBBBb4","id":41,"linkId":"","price":500,"description":"This building video showcases a luxury building located in the Financial District. It includes shots of the building exterior, lobby, and outdoor areas. A sample apartment is also showcased.","name":"Apartment Building","reel":false,"type":0,"approximateTime":3},{"blobkey":"AMIfv95JWHFzuK0BYadlQM61VQyOuGE5rT-buMuFLmXk7Dj4GFE_AAtniI4nuL5kD94O6K7zor6RvPcnsCKcTbx4KM8oN0apq0BHS5rTlUs4-Xww9MvdVvvANGOVovyrzlAswcI6vFZ6","id":42,"linkId":"","price":0,"description":"My reel showcases snippets from past video projects. It should communicate my personal aesthetic when shooting and editing. ","name":"My Reel","reel":true,"type":0,"approximateTime":0},{"blobkey":"AMIfv97pnf1y8Aek4RCX8c2uaAsLVc91o00JoP5l2Fk7XiWKCxCVBCAxPmMjjV5aUfgmAI2tadxyCfns6FIcQR12Lv-JaTdyJjIYYIUVyWy8iI3eBtKkJ9cxikXaPsprYGt642-U379A","id":43,"linkId":"","price":700,"description":"The Bean is a neighborhood coffee shop located in the East Village. In addition to capturing the physical space, this video contains commentary from regular customers.","name":"Coffee Shop Video","reel":false,"type":0,"approximateTime":3},{"blobkey":"AMIfv96EUXtcTd166Lg0MqeL7UA6zWYGA7AVkw1ltGf088xwkjWXDvhaG3M6rBsf6Jwz6MGTCQkhDJiVRSc-EyMIebt0SVzR9eXNI879sTATNQPvXsp0c3xL4yRJ6WQ2MfT90XMwm8pC","id":44,"linkId":"","price":1500,"description":"This video is a client testimonial for Yesware, an email marketing software company. It contains comments from three Yesware customers. ","name":"Client Testimonial","reel":false,"type":0,"approximateTime":14},{"blobkey":"AMIfv97QwJlN6K3GebdJQASXRRKcrxOjHnZcEocZ_Urab5539_jc6AeuGqDrj6jCv4RVIJcyNeb0b3-5odxGjlLqU76yPPGq8P6Au3AS30arXsy3PWKhniX6y4p4CLAIPv7XJdA0_mxM","id":45,"linkId":"","price":500,"description":"Bond New York, a Manhattan real estate agency, hosts an art event each month. This video recap includes testimonials by attendees as well as b-roll. ","name":"Event Sample","reel":false,"type":0,"approximateTime":4},{"blobkey":"AMIfv96_narMmT6tdnhD5KkVJ_oJ0wZpqGGTvM15xc9tpFlHLTd6vjLLfLw0Ak5awfc5Lge9_zK0W5w1tHktmc8mftQdbPIgXlyPKE02y1X4lGF0bkRtRhX6h7834R0yLnsEluIDwvgu","id":46,"linkId":"","price":1000,"description":"A roundtable discussion with StreetEasy correspondent, Sofia, and John Gomes/Fredrik Eklund of Prudential Douglas Elliman. The pair are established agents in the luxury market -- and you may recognize Fredrik from the Bravo TV series Million Dollar Listing. Watch the video for an animated discussion of contract activity and median prices.","name":"StreetEasy Roundtable Discussion","reel":false,"type":0,"approximateTime":4},{"blobkey":"AMIfv95HNN_nA11jaNdleFkrLfIVlMJvEvLu8kRrUaybhG1VKAj6f2SUZBvdCX7PN_xuScXzpVFE8ci77pJtcXh-D9qoEjgkJ9sK6MAu9M8mgxPg5p43UXcJ1VoyPE23YnOfmWvyCE03","id":47,"linkId":"","price":500,"description":"Client testimonial shot for Clevertech, a software development company. The subject is Amy Epstein, the managing director at ABI, a public relations firm.","name":"Client Testimonial ","reel":false,"type":0,"approximateTime":3},{"blobkey":"AMIfv95tEXCSJtLP1w_MWnmx21L2OlxQGap4PXIc7aqZbbnm0ZMOwiNSbECrXx2nuscDrZyd4Joq6eiRUFBZxKACpCVGQVvLpLfjyVGRHvTUFOYtk9ZnFTzM_GVukKDX3-0dESm5JJMl","id":48,"linkId":"","price":400,"description":"The Bean, a coffee shop located in the East Village, offers a frozen coffee beverage called the Frozen Mona Lisa. This video shows an employee making one from start to finish.","name":"Product Video: Frozen Mona Lisa","reel":false,"type":0,"approximateTime":2},{"blobkey":"AMIfv97s4c7JQtKM147oJzHZFNtFqIBhZARUCxZdrui7xI1RXUfolrRchfRhzCERdcgVtid5_-dE75jnKBHHh3CtBSRDFnnhlQjMpHRVkAhA5kVH0ExezSkrdi0GoPClfHLvaGrFo8gW","id":49,"linkId":"","price":300,"description":"An apartment video shot for East Village Apartments. It includes shots of the building exterior as well as a comprehensive look in the interior: bedroom, bathroom, living room, kitchen etc\u2026","name":"Apartment Video","reel":false,"type":0,"approximateTime":3},{"blobkey":"AMIfv94YHo2Xx_3LVYhvngnm_cSEoLu-8btAgCl57YYrcqHtMbrdAFvdzq9D5fE525xkK5tv0E_e_7zqNU8r_e_DMnFcA_iRBKLdKuHKpp74t8fJrTatTBlLFKPjIGcDcmjiIVx4cpy5","id":53,"linkId":"","price":1000,"description":"","name":"Coffee Shop Overview: The Bean","reel":false,"type":0,"approximateTime":5},{"id":59,"linkId":"SAAIFzlgOhQ","price":0,"description":"dzdzdzdzdzdzdz","name":"zdzddzdzdzdz","reel":false,"type":1,"approximateTime":0},{"id":60,"linkId":"dGghkjpNCQ8","price":2,"description":"effefe","name":"effefe","reel":false,"type":1,"approximateTime":2},{"id":63,"linkId":"1q-ZqbK2g3Y","price":400,"description":"Created for \"The Young Republican\" campaign. Commissioned by the republican activist Geoff Harbough.","name":"3D Motion graphics sample","reel":false,"type":1,"approximateTime":2},{"id":64,"linkId":"kiGkV1_1V3U","price":450,"description":"This unofficial video was edited and presented to the artist Nadia Kay as a one of the broadcast versions. Copyright of Silver Curve Records.","name":"Music video edit sample","reel":false,"type":1,"approximateTime":5}]');

我收到此错误:“未捕获的语法错误:意外的令牌 T”

JSFiddle:http: //jsfiddle.net/C4jh5/

4

1 回答 1

15

您应该正确转义引号:

... ,"description":"Created for \\"The Young Republican\\" campaign. Commissioned by the republican activist Geoff Harbough.", ...

演示:http: //jsfiddle.net/C4jh5/1/

于 2012-11-12T21:05:26.730 回答