解析有效的JSON得到“SyntaxError:Unexpected token ILLEGAL”

时间:2015-02-06 03:36:43

标签: javascript json

JSON已经过验证。但是当我用JSON.parse(),$ .parseJSON()或eval()解析它时。我得到了

  

“SyntaxError:意外的标记ILLEGAL”

这里是JSON:https://pastebin.com/cXMTw9Xu

我可以使用json_decode()解析它,所以我尝试了json_encode()然后将结果复制到javascript解析。但是我仍然遇到这个错误。

要重现,请尝试在任何浏览器的控制台中执行此脚本。

JSON.parse('{"id":"mindmaps","options":{"id":"mindmaps","instance":"","name":"","description":"","containerStyle":{"width":"auto","height":"auto"},"viewPort":{"width":50000,"height":50000,"allowDrag":true,"left":3819,"top":4422,"originalWidth":50000,"zoom":{"w":50000,"h":50000,"l":3895,"t":4457,"r":1},"originalHeight":50000},"enabled":true,"showBirdsEye":false,"sizeOfBirdsEye":200,"showMultiSelect":false,"showZoom":false,"showStatus":false,"collaboration":{"allow":false,"showPanel":true,"useLongPolling":false,"jsonp":false,"localizedOnly":false,"userName":"","userProfile":"","userIP":"","sizeOfBirdsEye":200,"hubName":"slateHub","url":"","callbacks":{"onCollaboration":null,"onCollaborationStarted":null,"onCollaborationWired":null,"onUnauthorized":null}},"isPublic":false,"imageFolder":"http:\/\/static.slatebox.com\/cursors\/"},"nodes":[{"options":{"id":"first_node","name":"first_node","text":"\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e01\u0e32\u0e23\u0e14\u0e33\u0e40\u0e19\u0e34\u0e19\u0e01\u0e32\u0e23\/\u0e41\u0e19\u0e27\u0e17\u0e32\u0e07","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":3635.515625,"yPos":4810,"height":74,"width":183.96875,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#ADD8C7-#59a989","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"rectangle","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"49701c9265cc","parentId":"first_node","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"e51346f8ebd7","parentId":"first_node","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"first_node","parentId":"ca6e34182a01","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"first_node","parentId":"56268f01d021","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"first_node","parentId":"8dd3e58e9e08","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"49701c9265cc","name":"first_node","text":"\t\u0e43\u0e2b\u0e49\u0e1c\u0e39\u0e49\u0e1e\u0e34\u0e01\u0e32\u0e23\u0e40\u0e1b\u0e47\u0e19\u0e04\u0e19\u0e40\u0e25\u0e37\u0e2d\u0e01 \n\u0e1e\u0e23\u0e49\u0e2d\u0e21\u0e41\u0e19\u0e1a\u0e43\u0e1a\u0e40\u0e2a\u0e19\u0e2d\u0e23\u0e32\u0e04\u0e32 \u0e41\u0e25\u0e30\u0e23\u0e39\u0e1b \n\u0e41\u0e25\u0e30\u0e21\u0e35\u0e01\u0e32\u0e23\u0e23\u0e31\u0e1a\u0e1b\u0e23\u0e30\u0e01\u0e31\u0e19\u0e44\u0e21\u0e48\u0e19\u0e49\u0e2d\u0e22\u0e01\u0e27\u0e48\u0e32 1 \u0e1b\u0e35","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4001,"yPos":4437,"height":69.21875,"width":234.59375,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}},"showParentArrow":false,"showChildArrow":false,"reattachable":true},"relationships":{"parents":[],"associations":[{"childId":"49701c9265cc","parentId":"first_node","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"e51346f8ebd7","name":"first_node","text":"\u0e43\u0e2b\u0e49\u0e1c\u0e39\u0e49\u0e1e\u0e34\u0e01\u0e32\u0e23\u0e40\u0e1b\u0e47\u0e19\u0e1c\u0e39\u0e49\u0e21\u0e32\u0e02\u0e2d\u0e40\u0e2d\u0e07 \n(\u0e22\u0e01\u0e40\u0e27\u0e49\u0e19\u0e19\u0e2d\u0e19\u0e40\u0e15\u0e35\u0e22\u0e07)","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":3999,"yPos":4514.9921875,"height":62.609375,"width":239.375,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"e51346f8ebd7","parentId":"first_node","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"e51346f8ebd7","parentId":"194a2c2bc36f","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"e51346f8ebd7","parentId":"cff7f9a59c1c","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"194a2c2bc36f","name":"first_node","text":"\t\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e14\u0e39\u0e27\u0e48\u0e32\u0e21\u0e35\u0e04\u0e27\u0e32\u0e21\u0e2d\u0e34\u0e2a\u0e23\u0e30\u0e43\u0e19\u0e01\u0e32\u0e23\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e40\u0e2d\u0e07\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4298.375,"yPos":4476.9921875,"height":67.609375,"width":231.375,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"e51346f8ebd7","parentId":"194a2c2bc36f","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"cff7f9a59c1c","name":"first_node","text":"\t\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e14\u0e39\u0e27\u0e48\u0e32\u0e02\u0e2d\u0e40\u0e2d\u0e07\u0e08\u0e23\u0e34\u0e07\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4302.75,"yPos":4546.9921875,"height":66.609375,"width":228.375,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"e51346f8ebd7","parentId":"cff7f9a59c1c","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"ca6e34182a01","name":"first_node","text":"\u0e21\u0e35\u0e19\u0e31\u0e01\u0e01\u0e32\u0e22\u0e20\u0e32\u0e1e\u0e08\u0e32\u0e01\u0e42\u0e23\u0e07\u0e1e\u0e22\u0e32\u0e1a\u0e32\u0e25\u0e1e\u0e23\u0e30\u0e21\u0e07\u0e01\u0e38\u0e0e \n\u0e0a\u0e48\u0e27\u0e22\u0e27\u0e34\u0e40\u0e04\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e04\u0e27\u0e32\u0e21\u0e40\u0e2b\u0e21\u0e32\u0e30\u0e2a\u0e21","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4002.46875,"yPos":4657.5,"height":61,"width":245.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"first_node","parentId":"ca6e34182a01","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"ca6e34182a01","parentId":"ca514c19c067","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"ca6e34182a01","parentId":"9df922474ff8","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"ca514c19c067","name":"first_node","text":"\t\u0e27\u0e34\u0e40\u0e04\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e2a\u0e20\u0e32\u0e1e\u0e04\u0e27\u0e32\u0e21\u0e1e\u0e34\u0e01\u0e32\u0e23","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4303.5,"yPos":4617.5,"height":62,"width":238.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"ca6e34182a01","parentId":"ca514c19c067","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"9df922474ff8","name":"first_node","text":"\t\u0e14\u0e39\u0e04\u0e27\u0e32\u0e21\u0e40\u0e2b\u0e21\u0e32\u0e30\u0e2a\u0e21\u0e02\u0e2d\u0e07\u0e2d\u0e38\u0e1b\u0e01\u0e23\u0e13\u0e4c\u0e17\u0e35\u0e48\u0e04\u0e27\u0e23\u0e43\u0e0a\u0e49","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4308.53125,"yPos":4694.5,"height":65,"width":242.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"ca6e34182a01","parentId":"9df922474ff8","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"56268f01d021","name":"first_node","text":"\u0e04\u0e13\u0e30\u0e01\u0e23\u0e23\u0e21\u0e01\u0e32\u0e23","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4013.5625,"yPos":4911.5,"height":64,"width":238.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"first_node","parentId":"56268f01d021","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"56268f01d021","parentId":"50e87752c77e","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"56268f01d021","parentId":"1af5c25a2616","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"56268f01d021","parentId":"26e6b42303bd","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"56268f01d021","parentId":"616e1d6aba5a","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"50e87752c77e","name":"first_node","text":"\t\u0e08\u0e30\u0e1e\u0e34\u0e08\u0e32\u0e23\u0e13\u0e32\u0e40\u0e1e\u0e14\u0e32\u0e19\u0e23\u0e32\u0e04\u0e32\u0e43\u0e19\u0e15\u0e25\u0e32\u0e14 \n\u0e1b\u0e31\u0e08\u0e08\u0e38\u0e1a\u0e31\u0e19\u0e21\u0e35\u0e01\u0e32\u0e23\u0e15\u0e31\u0e49\u0e07\u0e23\u0e32\u0e04\u0e32\u0e01\u0e25\u0e32\u0e07","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4313.375,"yPos":4766.5,"height":67,"width":244.4375,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"56268f01d021","parentId":"50e87752c77e","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"1af5c25a2616","name":"first_node","text":"\t\u0e41\u0e1a\u0e48\u0e07\u0e40\u0e1b\u0e47\u0e19 2 \u0e01\u0e25\u0e38\u0e48\u0e21","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4311.40625,"yPos":4838.5,"height":67,"width":239.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"56268f01d021","parentId":"1af5c25a2616","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"1af5c25a2616","parentId":"189e023daafc","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"1af5c25a2616","parentId":"c6d478066d47","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"189e023daafc","name":"first_node","text":"\u0e01\u0e25\u0e38\u0e48\u0e21\u0e17\u0e35\u0e48\u0e44\u0e21\u0e48\u0e21\u0e35\u0e1b\u0e31\u0e0d\u0e2b\u0e32 \u0e0a\u0e31\u0e14\u0e40\u0e08\u0e19","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4574.4375,"yPos":4786.5,"height":72,"width":190.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"1af5c25a2616","parentId":"189e023daafc","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"c6d478066d47","name":"first_node","text":"\u0e01\u0e25\u0e38\u0e48\u0e21\u0e17\u0e35\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e21\u0e35\u0e01\u0e32\u0e23\u0e1e\u0e34\u0e08\u0e32\u0e23\u0e13\u0e32","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4572.46875,"yPos":4898.5,"height":76,"width":181.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"1af5c25a2616","parentId":"c6d478066d47","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"c6d478066d47","parentId":"cd0f3786b7fe","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"c6d478066d47","parentId":"fedcba0e0c21","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"cd0f3786b7fe","name":"first_node","text":"\u0e01\u0e25\u0e38\u0e48\u0e21\u0e17\u0e35\u0e48\u0e44\u0e21\u0e48\u0e21\u0e35\u0e04\u0e27\u0e32\u0e21\u0e0a\u0e31\u0e14\u0e40\u0e08\u0e19\n\u0e43\u0e19\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e04\u0e27\u0e32\u0e21\u0e1e\u0e34\u0e01\u0e32\u0e23","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4819.5,"yPos":4847.5,"height":78,"width":201.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"c6d478066d47","parentId":"cd0f3786b7fe","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"fedcba0e0c21","name":"first_node","text":"\t\u0e01\u0e25\u0e38\u0e48\u0e21\u0e17\u0e35\u0e48\u0e44\u0e21\u0e48\u0e40\u0e2b\u0e21\u0e32\u0e30\u0e2a\u0e21\u0e02\u0e2d\u0e07\u0e2d\u0e38\u0e1b\u0e01\u0e23\u0e13\u0e4c","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4817.53125,"yPos":4953.5,"height":82,"width":196.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"c6d478066d47","parentId":"fedcba0e0c21","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"26e6b42303bd","name":"first_node","text":"\t\u0e40\u0e01\u0e13\u0e11\u0e4c\u0e01\u0e32\u0e23\u0e43\u0e2b\u0e49\u0e04\u0e30\u0e41\u0e19\u0e19","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4310.59375,"yPos":5041.5,"height":64,"width":238.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"56268f01d021","parentId":"26e6b42303bd","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"26e6b42303bd","parentId":"fe305f32d96a","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"26e6b42303bd","parentId":"c7d3cbe98b17","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"fe305f32d96a","name":"first_node","text":"\u0e17\u0e33\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e44\u0e23\u0e44\u0e21\u0e48\u0e43\u0e2b\u0e49\u0e15\u0e49\u0e2d\u0e07\u0e1e\u0e36\u0e48\u0e07\u0e04\u0e27\u0e32\u0e21\u0e23\u0e39\u0e49\u0e2a\u0e36\u0e01 \n(\u0e2d\u0e30\u0e44\u0e23\u0e17\u0e35\u0e48\u0e1c\u0e25\u0e15\u0e48\u0e2d\u0e04\u0e27\u0e32\u0e21\u0e1e\u0e34\u0e01\u0e32\u0e23 \u0e17\u0e35\u0e48\u0e08\u0e33\u0e40\u0e1b\u0e47\u0e19\u0e15\u0e49\u0e2d\u0e07\u0e21\u0e35\u0e2d\u0e38\u0e1b\u0e01\u0e23\u0e13\u0e4c)","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4601.75,"yPos":5000.5,"height":78,"width":260.625,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"26e6b42303bd","parentId":"fe305f32d96a","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"c7d3cbe98b17","name":"first_node","text":"\u0e40\u0e23\u0e34\u0e48\u0e21\u0e2a\u0e48\u0e07\u0e43\u0e2b\u0e49\u0e15\u0e48\u0e32\u0e07\u0e08\u0e31\u0e07\u0e2b\u0e27\u0e31\u0e14\u0e43\u0e0a\u0e49\u0e40\u0e01\u0e13\u0e11\u0e4c\u0e19\u0e35\u0e49\n\u0e43\u0e19\u0e01\u0e32\u0e23\u0e1e\u0e34\u0e08\u0e32\u0e23\u0e13\u0e32\u0e40\u0e2d\u0e07\u0e41\u0e25\u0e49\u0e27 (\u0e43\u0e19\u0e2d\u0e14\u0e35\u0e15\u0e1e\u0e36\u0e48\u0e07\u0e2a\u0e48\u0e27\u0e19\u0e01\u0e25\u0e32\u0e07)","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4603.75,"yPos":5087.5,"height":77,"width":264.0625,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"26e6b42303bd","parentId":"c7d3cbe98b17","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"616e1d6aba5a","name":"first_node","text":"\u0e2d\u0e19\u0e38\u0e21\u0e31\u0e15\u0e34","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4305.59375,"yPos":5129.5,"height":64,"width":238.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"56268f01d021","parentId":"616e1d6aba5a","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"8dd3e58e9e08","name":"first_node","text":"-\t\u0e15\u0e2d\u0e19\u0e08\u0e48\u0e32\u0e22\u0e40\u0e07\u0e34\u0e19 \u0e08\u0e30\u0e43\u0e2b\u0e49\u0e1e\u0e1a\u0e01\u0e31\u0e19 3 \u0e1d\u0e48\u0e32\u0e22 \n\u0e44\u0e14\u0e49\u0e41\u0e01\u0e48 \u0e01\u0e23\u0e21\u0e2f \u0e1c\u0e39\u0e49\u0e1e\u0e34\u0e01\u0e32\u0e23 \u0e41\u0e25\u0e30\u0e1c\u0e39\u0e49\u0e08\u0e33\u0e2b\u0e19\u0e48\u0e32\u0e22","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4020.921875,"yPos":5126.5,"height":86,"width":244.40625,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"first_node","parentId":"8dd3e58e9e08","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}}]}');

解决

我刚刚发现如果我使用下面的脚本ajax这个JSON。它的工作就像一个魅力。

但是为什么它不适用于JSON.parse()仍然是未知的。

   $.ajax({
      dataType: 'JSON',
      method: 'GET',
      url: 'path/to/mindmaps.json'
   }).success(function(result)){
      console.log(result);
   }

1 个答案:

答案 0 :(得分:0)

你正在做的一切正确,你只缺少一件:

JSON.parse和$ .parseJSON期待字符串,而不是对象。如果你把那个巨型glob放到任何一个函数中,它们就不会工作(你得到了你现在看到的堆栈跟踪。)

相反,如果您执行以下操作......

var copyPasteJson = /* your json here */ ;
var parsedResult = JSON.parse(JSON.stringify(copyPasteJson));

此处的完整示例:http://jsfiddle.net/xhx47ghg/

尽管如此......你不需要经历将copyPasteJson转换为字符串并返回json的麻烦,你可以简单地使用对象文字,{{1} }。