Home Web Front-end JS Tutorial How to get the length of JSON field in JS

How to get the length of JSON field in JS

Mar 08, 2018 pm 04:09 PM
javascript json get

JS Get the code for the length of the JSON field. This article will mainly share it with you in the form of code

//JS 获得JSON 字典的长度的代码  
  
var jsonData = {"name":"txt1","name2":"txt2"};  
  
function getJsonLength(jsonData) {  
  
    var jsonLength = 0;  
  
    for (var item in jsonData) {  
  
        jsonLength++;  
  
    }  
  
    return jsonLength;  
  
}  
  
console.log("json对象的长度为:",getJsonLength(jsonData));
Copy after login

The above is the detailed content of How to get the length of JSON field in JS. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get the Crimson Abyss of War Double Pamish Lucia How to get the Crimson Abyss of War Double Pamish Lucia Mar 25, 2024 pm 05:31 PM

Players can obtain Lucia's Crimson Abyss when playing in Battle Double Pamish. Many players don't know how to obtain Lucia's Crimson Abyss. Players can obtain it through research and development, or redeem it at the Phantom Pain Cage store. How to obtain R&D for Battle Double Pamish Lucia Crimson Abyss 1. Players can obtain it by drawing from the R&D system, which includes the base card pool, the theme limited card pool and the destiny limited card pool. 2. Revealed in these card pools The basic drop rate of Sia Crimson Abyss is 1.50%, but if the player draws Lucia Crimson Abyss from the card pool, the drop rate will increase to 1.90%. Redemption in the Phantom Pain Cage Store 1. Players can redeem fragments of Lucia Crimson Abyss by using Phantom Pain Scars in the Phantom Pain Cage Store. 2. You can redeem up to 30 fragments every week.

What is the difference between MySQL5.7 and MySQL8.0? What is the difference between MySQL5.7 and MySQL8.0? Feb 19, 2024 am 11:21 AM

MySQL5.7 and MySQL8.0 are two different MySQL database versions. There are some main differences between them: Performance improvements: MySQL8.0 has some performance improvements compared to MySQL5.7. These include better query optimizers, more efficient query execution plan generation, better indexing algorithms and parallel queries, etc. These improvements can improve query performance and overall system performance. JSON support: MySQL 8.0 introduces native support for JSON data type, including storage, query and indexing of JSON data. This makes processing and manipulating JSON data in MySQL more convenient and efficient. Transaction features: MySQL8.0 introduces some new transaction features, such as atomic

Performance optimization tips for converting PHP arrays to JSON Performance optimization tips for converting PHP arrays to JSON May 04, 2024 pm 06:15 PM

Performance optimization methods for converting PHP arrays to JSON include: using JSON extensions and the json_encode() function; adding the JSON_UNESCAPED_UNICODE option to avoid character escaping; using buffers to improve loop encoding performance; caching JSON encoding results; and considering using a third-party JSON encoding library.

How to obtain administrator rights in Win11 system How to obtain administrator rights in Win11 system Mar 08, 2024 pm 10:00 PM

It is very important to obtain administrator rights in the Win11 system, because administrator rights allow users to perform various operations in the system, such as installing software, modifying system settings, etc. Obtaining administrator rights in Win11 system can be achieved through the following methods: The first method is through user account control settings. In the Win11 system, User Account Control is a function used to manage user permissions. Through it, users can adjust their permission levels. To obtain administrator rights, users can enter the "Settings" interface and select "

How to get Eldon's Ring Torret How to get Eldon's Ring Torret Mar 11, 2024 am 11:40 AM

Torret is the spirit horse in the game Elden's Circle. Many players don't know how to obtain Torret of Elden's Circle. To summon Torret, players need to obtain the spirit horse whistle, which is equipped in the shortcut bar. After that, use the shortcut keys to summon the spirit horse Torret. How to obtain Torret of Eldon's Ring? Answer: You need to obtain the Whistle of the Spirit Horse. 1. Players need to obtain the Spirit Horse Whistle to summon Torret. 2. Players go from the novice birth point to the blessing point in front of the Storm Road, sit down by the campfire, and the heroine [Melina] will appear, and she will give you a [Spirit Horse Whistle] ring. 3. After players equip the "Spirit Horse Whistle" to the shortcut bar and then use the Spirit Horse Whistle, they can summon the soul of Thoret's horse. 4. After riding the spirit horse Torret, you can perform a double jump. You can jump while walking but cannot jump.

How do annotations in the Jackson library control JSON serialization and deserialization? How do annotations in the Jackson library control JSON serialization and deserialization? May 06, 2024 pm 10:09 PM

Annotations in the Jackson library control JSON serialization and deserialization: Serialization: @JsonIgnore: Ignore the property @JsonProperty: Specify the name @JsonGetter: Use the get method @JsonSetter: Use the set method Deserialization: @JsonIgnoreProperties: Ignore the property @ JsonProperty: Specify name @JsonCreator: Use constructor @JsonDeserialize: Custom logic

How to get the white-haired pipe in Gulong Fengyunlu How to get the white-haired pipe in Gulong Fengyunlu Feb 29, 2024 pm 01:04 PM

There are many achievements in the Gulong Fengyunlu game, some of which are related to collectibles. When we meet Sun Xiaohong, it will also trigger a story with Sun Baifa, in which Baifa Pipe needs to get this pipe to complete it. The following is Everyone brings you the method to achieve the Gulong Fengyun Record White Hair Pipe. How to achieve Gu Long Fengyun Lu's White-haired Pipe 1. This achievement needs to be noted after the end of Chapter 4 of Sun Xiaohong's favor task. 2. Sun Xiaohong informed that her grandfather was missing, and then went to Luoyang Changting to find the whereabouts of Sun Baifa. 3. After learning that Sun Baifa had died at the hands of Shangguan Jinhong, he found Sun Baifa's tobacco stem on the ground and obtained the "White Hair Pipe". Key points: If Sun Xiaohong’s last mission is completed before returning to the main hall of Renyi Village in Chapter 4, Sun Baifa will not be able to trigger Luoyang City after entering the village.

In-depth understanding of PHP: Implementation method of converting JSON Unicode to Chinese In-depth understanding of PHP: Implementation method of converting JSON Unicode to Chinese Mar 05, 2024 pm 02:48 PM

In-depth understanding of PHP: Implementation method of converting JSONUnicode to Chinese During development, we often encounter situations where we need to process JSON data, and Unicode encoding in JSON will cause us some problems in some scenarios, especially when Unicode needs to be converted When encoding is converted to Chinese characters. In PHP, there are some methods that can help us achieve this conversion process. A common method will be introduced below and specific code examples will be provided. First, let us first understand the Un in JSON

See all articles