In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to format JSON code in js. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Format JSON code
I'm sure you've all used the JSON.stringify method, which converts a JavaScript object or value into a JSON string. His grammar is as follows:
JSON.stringify (value, replacer, space)
It has three parameters:
Value: the value to be serialized into a JSON string.
Replacer optional: if the parameter is a function, each property of the serialized value will be converted and processed by the function during serialization; if the parameter is an array, only the property names contained in the array will be serialized to the final JSON string; if the parameter is null or not provided, all properties of the object will be serialized.
Space optional: specify a blank string for indentation to beautify the output (pretty-print); if the parameter is a number, it represents how many spaces it has; the upper limit is 10. If the value is less than 1, there are no spaces; if the parameter is a string (take the first 10 letters of a string when the length of the string exceeds 10 letters), the string will be used as a space; if the parameter is not provided (or null), there will be no spaces.
Typically, we write a parameter to convert a JavaScript object or value to a JSON string. You can see that it also has two optional parameters, so we can use them to format the JSON code:
Console.log (JSON.stringify ({alpha: 'Aids, beta:' B'}, null,'\ t'))
The output is as follows:
This is the end of this article on "how to format JSON code in js". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
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.