


json data processing skills (fields with spaces, adding fields, sorting, etc.)_javascript skills
May 16, 2016 pm 05:32 PM1. The normal value of json data: json[i].fieldName
2. The field of json data has spaces: eval('json[' i ']["' field '"]')
3. Assignment of json data: eval('json[' i ']["' field '"]=' jsonFilter.length);
4. Add fields to json data: loop all data , just json[i].newField=defaultValue
5. Sorting of json data: equivalent to sorting of arrays, json.sort(function (a, b) { return a[name] > b [name] ? 1 : -1 });
6. Copy of json data: var newObject = jQuery.extend(true, {}, oldObject); Please refer to: Copy of json object in jQuery (array and objects)
7. Adding and deleting json arrays, etc.: concat method | join method | pop method | push method | reverse method | shift method | slice method | sort method | splice method | toLocaleString method | toString method | unshift method | valueOf method
8. Example of creating a json array: var jsonArr=[]; var item={id:'id1',value:'val1'}; jsonArr.push(item); This creates a json array with two fields id and value, and adds a record to the array.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Combination of golang WebSocket and JSON: realizing data transmission and parsing

What is the difference between MySQL5.7 and MySQL8.0?

Performance optimization tips for converting PHP arrays to JSON

The difference between full-width spaces and half-width spaces

Pandas usage tutorial: Quick start for reading JSON files

Use the json.MarshalIndent function in golang to convert the structure into a formatted JSON string

How do annotations in the Jackson library control JSON serialization and deserialization?

How to handle XML and JSON data formats in C# development
