Among many jquery methods, many method parameters can be passed into a JSON object, such as the second parameter of the Ajax method. Note the following when converting text into a JSON object:
1) $. parsejson returns a string instead of a JSON object.
2) to convert a string into an object, it is easy to think of the eval method in JS. In fact, this is acceptable, but parentheses must be added. For example, var js = "{\" pageindex \ ": \" 1 \ "}"; var OBJ = eval ("(" + JS + ")");. However, using Eval is insecure because it can compile any JSCode.
3) download a JSON parser because it only recognizes JSON text. This makes it safer. The official JSON website provides such a script. Address: http://www.json.org/json2.js. It is easy to use. After the file is introduced, for example, JSON. parse ($ ("# search"). Val (). tostring ()).
4) when the JSON. parse method or the $. parsejson method is used,Note that the name and value of the JSON data are enclosed in double quotation marks. For the $. parsejson method, you must enclose the JSON string in single quotation marks before conversion. This is not required for the JSON. parse method.Really TMD is a waste of time.
Pay attention to these skills, so you can avoid a lot of detours when operating JSON data.