JSON format processing and extension

Source: Internet
Author: User
Tags hasownproperty

1 <Scriptsrc= "Http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></Script>2     <Script>3         //JSON extension Methods4         if (!Object.prototype.forEach) {5 Object.prototype.forEach= function(FN) {6                 Try {7                      for (varKeyinch  This) {8                         //determines whether a property is a property of the object itself. 9                         if ( This. hasOwnProperty (Key)) {Ten Fn.call ( This, Key, This[key]); One                            //fn.apply (this, [key, This[key]); A                         } -                     } -                 } Catch(e) { the                     Throwe; -                 } -             } -         } +     </Script>
JSON extension

    <Script>        varStringeap= '{"name": "Xiaoming", "Age": ""} "'; varJsoneap={name:'Xiao Ming', Age:' -' }; //JSON Delete        Deletejsoneap["name"];//or delete jsoneap.name;         //JSON Add modificationJsoneap.name= "Xiao Wang";//or jsoneap["name"]= "Xiao Wang "        //determine if the key exists in the JSONConsole.log (Jsoneap.hasownproperty ("name")); //JS processing JSON mode        //go to standard format JSON        varData=Json.parse (STRINGEAP); //JQ mode var dat= $.parsejson (stringeap)        vardata1=Eval ("(" +Stringeap+ ")"); //go to JSON string        varStringData=json.stringify (JSONEAP); Jsoneap.foreach (function(key, value) {Console.log (key, value);    }); </Script>

JSON format processing and extension

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.