json is not javascript; json is a lightweight data exchange format, and javascript is a lightweight, interpreted or just-in-time compiled programming language with function priority; the json format is derived from JavaScript Object, which is a subset of JavaScript.
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
Is json just javascript?
json is not javascript.
JSON (JavaScript Object Notation) is a lightweight data exchange format. JSON format data is mainly used for cross-platform exchange of data. JavaScript ("JS" for short) is a lightweight, interpreted or just-in-time compiled programming language with function priority.
But JSON and JavaScript do have origins. It can be said that this data format evolved from JavaScript objects and is a subset of JavaScript. JSON itself means JavaScript Object Notation, which uses strict JavaScript object notation to represent structured data.
It is a strict js object format. The attribute name of JSON must have double quotes. If the value is a string, it must also be double quotes;
JSON is just a data format (or data format), the data format is actually a specification. Format, form, and specification cannot be used to store data. We cannot call the following objects JSON, for example:
<script> var obj2={};//这只是JS对象 var obj3={width:100,height:200};/*这跟JSON就更不沾边了,只是JS的 对象 */ var obj4={'width':100,'height':200};/*这跟JSON就更不沾边了,只是JS的对象 */ var obj5={"width":100,"height":200,"name":"rose"}; /*我们可以把这个称做:JSON格式的JavaScript对象 */ var str1='{"width":100,"height":200,"name":"rose"}';/*我们可以把这个称做:JSON格式的字符串 */ var a=[ {"width":100,"height":200,"name":"rose"}, {"width":100,"height":200,"name":"rose"}, {"width":100,"height":200,"name":"rose"}, ]; /*这个叫JSON格式的数组,是JSON的稍复杂一点的形式 */ var str2='['+ '{"width":100,"height":200,"name":"rose"},'+ '{"width":100,"height":200,"name":"rose"},'+ '{"width":100,"height":200,"name":"rose"},'+ ']' ; /* 这个叫稍复杂一点的JSON格式的字符串 */ </script>
Recommended learning: "javascript basic tutorial"
The above is the detailed content of Is json equal to javascript?. For more information, please follow other related articles on the PHP Chinese website!