In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the role of JSON". In daily operation, I believe that many people have doubts about the role of JSON. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what is the use of JSON?" Next, please follow the editor to study!
What is JSON?
There is a lightweight data exchange format called JSON (JavaScript Object Notation) that can replace the work of XML. It is JSON.
The data format is relatively simple, easy to read and write, the format is compressed, and the bandwidth is small.
It is easy to parse this language, and the client JavaScript can simply read JSON data through eval ().
Including ActionScript, C, client, ColdFusion,Java,JavaScript,Perl,PHP,Python,Ruby and other languages, server-side languages to facilitate server-side analysis.
Languages support JSON particularly well, and JSON format transmission has become more popular since the popularity of Ajax.
Second, if you still don't understand when you get here? What is JSON, then I will make a big move!
In fact, when I am interviewing for the company, I often mention that if I don't know what JSON is? How can you tell me? let me know what it is. (the following is my personal understanding, because the understanding varies from person to person, it can be used! )
Asked so many people, in fact, the result is not what I want, most of the answers are these.
It is used for front-end and background interaction.
It is the key value right.
There are more of the above two points. Others are in a mess and deviate completely from JSON.
So what should it be like? It should be answered in this way, personally!
First of all, it's just a string, it's just a regular string. (key points)
Then it is expressed in the form of key-value pairs. In fact, it is very similar to the dictionary in Map,Objective-C in Java language, other languages have corresponding, to tell you the truth, I don't know other languages! Why do I use MapString generics, because theoretically its key-value pairs should all be strings, Why? That's a good question, and I can answer you this way, because it's a string.
What is the theoretical expression mentioned above, so what does the actual key-value pair we use support? Can support String, Number, Array as well as Boolean, null and so on.
Its function is used for interaction, not necessarily Web project front-end interaction can also interface, configuration files, file storage and so on are all OK. At present, the mobile terminal is quite popular, and general projects will be transmitted by JSON.
Third, what can it bring?
Simple, simple, small, etc.
Easy to use, efficient.
Cross-language. At present, the general project construction of Android and IOS on mobile is developed by the way that other languages provide the interface (JSON mode) and the mobile terminal reads the interface.
... .
4. Is it compared with XML?
Readability: after reading all kinds of posts on the Internet, it is said that the readability is quite good, but basically it means that XML has good readability, which I think is OK. We can draw.
Scalability: some people say, "XML is inherently scalable, and so is JSON. There is nothing that XML can extend and JSON can't. However, JSON fights at home in Javascript and can store Javascript composite objects, which has an incomparable advantage over XML." I agree with half of it. I think these posts are old posts. XML can be flexibly extended because there are other Jar packages, class libraries and so on supported by various languages. But since the popularity of JSON, JSON support packages, class libraries, etc., I believe that each language is very many. For example, Java has Jackson, goson, json-lib, FastJson and so on.
Coding difficulty: XML has DOM,SAX,STAX and other parsing technology, JSON also has what I mentioned above, all OK.
Decoding difficulty: ditto.
Decoding and coding efficiency: ha ha! There is a special CPU for parsing XML. Do you make it?
Here is a Demo.
XML Demo
China Heilongjiang, Harbin, Daqing, Guangdong, Guangzhou, Shenzhen, Zhuhai, Taiwan, Taipei, Kaohsiung, Xinjiang, Urumqi
JSON Demo
{"name": "China", "province": [{"name": "Heilongjiang", "citys": {"city": ["Harbin", "Daqing"]}}, {"name": "Guangdong", "citys": {"city": [Guangzhou "," Shenzhen "," Zhuhai "]}}, {" name ":" Taiwan " "citys": {"city": ["Taipei", "Kaohsiung"]}}, {"name": "Xinjiang", "citys": {"city": ["Urumqi"]}}]} json libraries commonly used by Java
We have to deal with JSON data in our daily development, so let's take a look at the common JSON parsing methods used in JAVA.
1. JSON official
2 、 GSON
3 、 FastJSON
4 、 jackson
At this point, the study on "what is the role of JSON" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.