JSON list Data Lookup update

Source: Internet
Author: User

/* Find records in a field from a JSON array inarray data list fieldname field name Fieldvalue field value out find the data list */var Searchrecordsfromjsonarra    y = function (array, fieldName, fieldvalue) {var result = [];            if ($.isarray (array)) {for (var i = 0; i < Array.Length; i++) {var rowitem = array[i];                    For (var item in Rowitem) {if (item = = FieldName && Rowitem[item] = = Fieldvalue) {                Result.push (Rowitem); }}}} return result; /* Modify the value of a record according to a field if it does not match the corresponding record, do not update the list of data inarray to update record new records fildname field name outarray Updated data list * /var Updaterecordbykey = function (array, record,fieldname) {if ($.isarray (array)) {for (var i = 0; i < arr Ay.length;            i++) {var rowitem = array[i];                    For (var item in Rowitem) {if (item = = FieldName && Rowitem[item] = = Fieldvalue) { Updates the matching record for (Var ri in Rowitem) {for (Var r in record) {if (ri = = r) {                            Rowitem[ri] = Record[r];        }}}}} Array[i] = Rowitem; }} return array;}
Look for all loops, to be improved

JSON list Data Lookup update

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.