1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "UTF-8">5 <title></title>6 </Head>7 <Body>8 <Script>9 varData= [Ten { One "value": 1, A "label": "Discerning Standard Products" - }, - { the "value": 2, - "label": "Big Data" - }, - { + "value": 3, - "label": "Big Linkage" + }, A { at "value": 4, - "label": "All-Family collection" - }, - { - "value": 5, - "label": "Railway Hu Lu" in }, - { to "value": 6, + "label": "Ping An China" - }, the { * "value": 7, $ "label": "Social Services"Panax Notoginseng } - ] the + functiondataprocessing (data) { A varI=0; Len=data.length; the varNewData= {}; + varDataarr= []; - for(i; I<Len; I++) { $ Dataarr.push ({ $ //the new key name - Linetype:data[i].value, - //the new value name the Linename:data[i].label - })Wuyi } the returnDataarr; - } Wu Console.log (dataprocessing (data));//incoming array to be processed - </Script> About </Body> $ </HTML>
Filter the key value in the array object, replace the key value with the key name and the value name we need