In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to analyze the origin of JSON, I believe that many inexperienced people are at a loss about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
This article introduces the origin of JSON, as well as the explanation of the origin of JSON, that is, we can put the statement we want to execute in a string and execute it through the dynamic execution function eval (). The contents of the string will be executed just like the script we wrote.
What about XML, a trendy cross-platform language? Actually, XML=TXT. XML is just text that conforms to many specifications. It is nothing in itself, but a file that saves characters. The browser reads only the text content on the server asynchronously, so you don't have to stick to XML when developing Ajax.
Introduction to the origin of JSON
The purpose of XML is to format the data content. Is there a better way if we don't use XML? The answer is the origin of JSON. Before I introduce JSON, let me introduce the script language of JavaScript. Scripting languages themselves have a gift for dynamic execution. That is, we can put the statement we want to execute in a string and execute it through the dynamic execution function eval (). The contents of the string will be executed just like the script we wrote.
Example 1:
< HTML > < HEAD > < TITLE > eval example 1 < / TITLE > < / HEAD > < BODY > < script > str = "alert (''hello'')"; eval (str); < / script > < / BODY > < / HTML > opens the page and the hello window pops up. We can put any script statement in the string, including declaration statements: < HTML > < HEAD > < TITLE > eval example 2 < / TITLE > < / HEAD > < BODY > < script > define = "{name:''Michael'',email:''17bity@gmail.com''}"; eval ("data =" + define); alert ("name:" + data.name); alert ("email:" + data.email) < / script > < / BODY > < / HTML >
If the text we send asynchronously in the background is a JavaScript declaration statement, then it can be parsed by not an eval method? How efficient it is to parse complex XML! I'm going to tell you what JSON:JavaScript Object Notation is. I prefer to translate it into a JavaScript object declaration. For example, to load some address book information from the background, if it is written as XML, it is as follows:
< contact > friend > < name > Michael < / name > < email > 17bity@gmail.com < / email > < homepage > http://www.jialing.net < / homepage > < / friend > < friend > < name > John < / name > < email > john@gmail.com < / email > < homepage > http://www.john.com < / homepage > < / friend > < friend > < name > Peggy < / name > < email > peggy@gmail.com < / email > < homepage > http://www.peggy.com < / homepage > < / friend > < / contact > and write it as JSON: [{name: "Michael" Email: "17bity@gmail.com", homepage: "http://www.jialing.net"}, {name:" John ", email:" john@gmail.com ", homepage:" http://www.jobn.com"}, {name: "Peggy", email: "peggy@gmail.com", homepage: "http://www.peggy.com"}] finish reading the above Have you mastered the method of analyzing the origin of JSON? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.