var dataobj=eval ("(" +data+ ")");//Convert to JSON object Why eval here, data is to be enclosed in "(", ")"? Cause: Because JSON starts and ends in the way "{}", in JS it is treated as a block of statements, so it must be coerced into an expression. The purpose of the parentheses is to force the Eval function to force the expression in parentheses to be converted to an object while processing the JavaScript code, rather than being executed as a statement (statement). For example, if the object literal {} is not enclosed, then eval will recognize the curly brace as the start and end tag of the JavaScript block, and {} will be considered an empty statement. So the following two execution results are different: alert (eval ("{}");//Return Undefinedalert ("({})");//return Object[object]
Excerpt from http://www.cnblogs.com/myjavawork/archive/2011/03/10/1979279.html
Why do I need parentheses when I use eval () to convert a Json object?