HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
One of the most common use of JSON, is read from the web server JSON data (as a file or as an HttpRequest), the JSON data into JavaScript objects, and then use that data in a Web page.
To make it easier for you to explain, we use string as input for presentation (rather than a file).
Create a JavaScript string containing the JSON syntax:
Since JSON syntax is a subset of JavaScript syntax, JavaScript eval () function can be used to convert the text to JSON JavaScript object.
eval () function uses JavaScript compiler can parse JSON text, and then generate JavaScript objects. The text must be enclosed in parentheses, so as to avoid syntax errors:
Using JavaScript objects in the page:
eval () function can compile and execute any JavaScript code. This hides a potential security issue.
Using JSON parser to convert JSON JavaScript object is a safer approach. JSON JSON text parser only recognizes, but does not compile the script.
In the browser, which provides native JSON support, JSON parsers and faster.
Newer browsers and the latest ECMAScript (JavaScript) standard contains native support for JSON is.
Web 浏览器支持 | Web 软件支持 |
---|---|
|
|
For older browsers can use JavaScript libraries: https://github.com/douglascrockford/JSON-js
JSON format was originally developed originally specified by Douglas Crockford