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/03 Report--
This article mainly shows you "how to use the json format", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use the json format" this article.
JSON (JavaScriptObjectNotation,JS object Spectrum) is a lightweight data exchange format. It is based on a subset of ECMAScript, the js specification developed by the European computer Association, and uses a text format that is completely independent of the programming language to store and represent data. The concise and clear hierarchical structure makes JSON an ideal data exchange language. It is easy for people to read and write, at the same time, it is also easy for machine analysis and generation, and effectively improve the efficiency of network transmission.
Common types of json format
Any supported type can be represented by JSON, such as strings, numbers, objects, arrays, and so on. But objects and arrays are two special and commonly used types.
Object: the object in JS is the content wrapped in curly braces {}, and the data structure is the key-value pair structure of {key1:value1,key2:value2,...}. In object-oriented languages, key is the property of the object and value is the corresponding value. Key names can be represented by integers and strings. The type of value can be any type.
Array: an array is wrapped in square brackets [] in JS. The data structure is ["java", "javascript", "vb",...] The index structure of the In JS, an array is a special data type. It can also use key-value pairs like objects, but indexes still use more. Similarly, the type of the value can be any type.
Basic example of json format
Simply put, JSON can convert a set of data represented in a JavaScript object into a string, and then easily pass the string between networks or programs, and restore it to the data format supported by various programming languages when needed, such as in PHP, you can restore JSON to an array or a basic object. When using AJAX, if you need to use an array to pass values, you need to use JSON to convert the array to a string. [3]
Representation object
Object is an unordered collection of name / value pairs. An object begins with {opening parenthesis and ends with} closing parenthesis. Each "name" is followed by a colon; "name / value pairs" are separated by commas.
one
{"firstName": "Brett", "lastName": "McLaughlin"}
Representation array
Like a normal JS array, JSON represents an array in square brackets [].
{
"people": [
{
"firstName": "Brett"
"lastName": "McLaughlin"
}
{
"firstName": "Jason"
"lastName": "Hunter"
}
]
}
It's not hard to understand. In this example, there is only one variable named people, and the value is an array of two entries, each of which is a person's record, containing the first and last name. The above example shows how to combine records into a single value with parentheses. Of course, you can use the same syntax to represent more than one value (each value contains multiple records).
There are no predefined constraints that need to be followed when working with data in JSON format. Therefore, in the same data structure, you can change the way the data is represented, or you can use different ways to represent the same thing.
As mentioned earlier, in addition to objects and arrays, you can also simply use strings or numbers to store simple data, but this doesn't make much sense.
The above is all the content of this article "how to use json format". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.