JavaScript中遍历JSON对象,获取所有的键Key及对应的值Value

2017年11月06日 其他资源 11条评论 阅读2240次


JavaScript中遍历JSON对象,打印所有的键Key及值Value。


var obj = {"key1":"val1", "key2":"val2"};
var str = "";
for (var p in obj) {
    str = str + (p + " = " + obj[p]) + ", ";
}
console.log(str);


遍历JSON对象后输出的键值字符串为:

key1 = val1, key2 = val2, 

分享本文至:

WRITTEN BY

avatar
本文标签:jsonJavaScript
看了本文是不是觉得很赞,那就赶紧点击下面按钮分享给身边的朋友吧!

11 条评论

  1. avatar hbshbuick

    <a href="http://www.jobbstockholm.com/nike-lebron-12-lilla-bl%C3%A5-butyf">nike lebron 12 lilla bl氓</a> <a href="http://www.johnklymshyn.com/nike-air-max-2015-svart-oransje-butyf">nike air max 2015 svart oransje</a> <a href="http://www.medicinennet.com/asics-gel-hyper-33-hombres-corriendo-zapatos-underneath-obuvf">asics gel hyper 33 hombres corriendo zapatos underneath</a> <a href="http://www.nereephotos.com/nike-air-max-90-blanc-argent-obuve">nike air max 90 blanc argent</a> <a href="http://www.nutraxtractor.com/yeezy-boost-350-s%C3%B8lv-gr%C3%B8nn-kurpesg">yeezy boost 350 s酶lv gr酶nn</a> <a href="http://www.resqglobal.com/air-jordan-melo-hvit-himmelen-bl%C3%A5-obuvc">air jordan melo hvit himmelen bl氓</a>
    hbshbuick http://www.hbshbuick.com/

  2. avatar puyichinese

    <a href="http://www.haerinonghyup.com/game-d.j.-humphries-youth-jersey-arizona-cardinals-74-alternate-black-nfld">game d.j. humphries youth jersey arizona cardinals 74 alternate black</a> <a href="http://www.burkkinc.com/nike-roshe-run-speckle-mujeres-p%C3%BArpura-skoc">nike roshe run speckle mujeres p煤rpura</a> <a href="http://www.magicstockdz.com/burberry-scarf-europe-scarfr">burberry scarf europe</a> <a href="http://www.soldthekayway.com/cheap-nike-air-free-mens-grey-sneakerc">cheap nike air free mens grey</a> <a href="http://www.medsydobrasil.com/air-jordan-7-retro-numbered-shoese">air jordan 7 retro numbered</a> <a href="http://www.schokostueck.com/ray-ban-clubmaster-tortoise-51-sunglassesr">ray ban clubmaster tortoise 51</a>
    puyichinese http://www.puyichinese.com/

  3. avatar freemoviesaz

    <a href="http://www.agriind.com/michael-kors-jet-set-travel-flat-trifold-wallet-mkr">michael kors jet set travel flat trifold wallet</a> <a href="http://www.rapheroes.com/nike-roshe-flyknit-durability-sneakere">nike roshe flyknit durability</a> <a href="http://www.odubmusic.com/aaron-maybin-jersey-new-york-jets-51-youth-white-limited-jersey-nike-jersey-nflb">aaron maybin jersey new york jets 51 youth white limited jersey nike jersey</a> <a href="http://www.kidbleach.com/billig-nike-air-force-1-flyknit-low-herre-gr%C3%B8n-shoesc">billig nike air force 1 flyknit low herre gr酶n</a> <a href="http://www.shoppula.com/air-jordan-retro-5-mens-orange-green-skog">air jordan retro 5 mens orange green</a> <a href="http://www.kanpourakuen.com/adidas-eqt-kids-shoes-yellow-red-sportsf">adidas eqt kids shoes yellow red</a>
    freemoviesaz http://www.freemoviesaz.com/

  4. avatar powfarm

    <a href="http://www.divyangmart.com/nike-air-max-2015-herren-for-verkauf-website-scarpeb">nike air max 2015 herren for verkauf website</a> <a href="http://www.ezellhvac.com/nike-air-max-2019-green-uk-shoeso">nike air max 2019 green uk</a> <a href="http://www.oldoyopark.com/nike-air-max-97-gr%C3%A5-s%C3%B8lv-kurpesb">nike air max 97 gr氓 s酶lv</a> <a href="http://www.racquetlady.com/menu-adidas-gazelle-bb5477-couk-zapatost">menu adidas gazelle bb5477 couk</a> <a href="http://www.ankaralokanta.com/converse-femme-all-star-blanche-shoesz">converse femme all star blanche</a> <a href="http://www.mengenmetal.com/nike-kd-vii-lifestyle-r%C3%B8d-schuhec">nike kd vii lifestyle r酶d</a>
    powfarm http://www.powfarm.com/

  5. avatar litpower

    <a href="http://www.abcmaster.net/adidas-nmd-runner-vapour-rose-light-onix-butya">adidas nmd runner vapour rose light onix</a> <a href="http://www.abracadabranche.net/jordan-flight-23-rouge-noir-schuhea">jordan flight 23 rouge noir</a> <a href="http://www.accademiadeilincei.net/nike-air-max-lunar-1-viola-schuheb">nike air max lunar 1 viola</a> <a href="http://www.addaxia.net/asics-gel-kayano-20-bl%C3%A5-jays-butyc">asics gel kayano 20 bl氓 jays</a> <a href="http://www.adultlivesexx.net/nike-sb-dunk-low-pigeon-for-salg-obuvf">nike sb dunk low pigeon for salg</a> <a href="http://www.affluentadvisors.net/air-jordan6-gr%C3%BCn-gold-obuvf">air jordan6 gr眉n gold</a>
    litpower http://www.litpower.net/

  6. avatar kmkonka

    <a href="http://www.guerotacos.com/jordan-5-fire-rojo-pre-order-chaussuresf">jordan 5 fire rojo pre order</a> <a href="http://www.printonlitpro.com/nike-roshe-sort-light-ash-gr%C3%A5-scarpef">nike roshe sort light ash gr氓</a> <a href="http://www.tvpchicago.com/womens-chuck-bednarik-limited-olivecamo-nike-jersey-nfl-philadelphia-eagles-60-super-bowl-lii-2017-salute-to-service-nfls">womens chuck bednarik limited olivecamo nike jersey nfl philadelphia eagles 60 super bowl lii 2017 salute to service</a> <a href="http://www.yesbobdylan.com/ralph-lauren-tees-bl%C3%A5-svart-polox">ralph lauren tees bl氓 svart</a> <a href="http://www.coypon.com/giants-8-hunter-pence-grey-road-2-new-cool-base-stitched-mlb-jersey-nflz">giants 8 hunter pence grey road 2 new cool base stitched mlb jersey</a> <a href="http://www.lottoalm.com/jordan-13-blanc-rouge-and-noir-kurpesd">jordan 13 blanc rouge and noir</a>
    kmkonka http://www.kmkonka.com/

  7. avatar r011o9ov

    <a href="http://www.1soiyu28.com/nike-kobe-6-sortout-instructions-obuva">nike kobe 6 sortout instructions</a> <a href="http://www.cx77f2er.com/nike-zoom-structure-20-lyser%C3%B8d-gul-butyc">nike zoom structure 20 lyser酶d gul</a> <a href="http://www.7x8rq331.com/air-jordan-14-hyper-rose-huaraches-scarpeb">air jordan 14 hyper rose huaraches</a> <a href="http://www.it6zdy3w.com/nike-free-flyknit-chukka-rosso-nero-kurpesf">nike free flyknit chukka rosso nero</a> <a href="http://www.ybavsh19.com/flyknit-trainer-azul-glow-face-scarpea">flyknit trainer azul glow face</a> <a href="http://www.2n946caj.com/air-jordan-retro-10-bambini-bianca-nero-obuvc">air jordan retro 10 bambini bianca nero</a>
    r011o9ov http://www.r011o9ov.com/

  8. avatar dumpthatdebt

    <a href="http://www.starizle.com/nike-mercurial-vapor-jaune-noir-kurpesb">nike mercurial vapor jaune noir</a> <a href="http://www.notpotatoes.com/hvit-jordan-12-ovo-kurpesd">hvit jordan 12 ovo</a> <a href="http://www.tedxuon.com/air-jordan-retro-14-ni%C3%B1os-naranja-verde-kurpesc">air jordan retro 14 ni帽os naranja verde</a> <a href="http://www.thejuicylucy.com/nike-air-max-97-femminile-blu-rosa-scarpec">nike air max 97 femminile blu rosa</a> <a href="http://www.almanyaonline.com/nike-air-huarache-iii-gr%C3%A5-rosa-schuhee">nike air huarache iii gr氓 rosa</a> <a href="http://www.trademelikes.com/air-jordan-retro-5-rosado-obuvf">air jordan retro 5 rosado</a>
    dumpthatdebt http://www.dumpthatdebt.com/

  9. avatar bq1fidt1

    <a href="http://www.b7tb99r5.com/nike-air-max-thea-rot-zombies-butya">nike air max thea rot zombies</a> <a href="http://www.0hicvn40.com/adidas-superstar-gs-svart-hvit-foundation-scarpee">adidas superstar gs svart hvit foundation</a> <a href="http://www.1o5i1ylp.com/free-flyknit-5.0-tr-training-scarpa-width-butyf">free flyknit 5.0 tr training scarpa width</a> <a href="http://www.yzdmnx48.com/nike-mercurial-superfly-rouge-and-violet-butyf">nike mercurial superfly rouge and violet</a> <a href="http://www.4vgdg8la.com/nike-kd-9-rosa-oro-schuhea">nike kd 9 rosa oro</a> <a href="http://www.svmn5v0b.com/nike-kaishi-gr%C3%B8n-zone-chaussuresa">nike kaishi gr酶n zone</a>
    [url=http://www.bq1fidt1.com/]bq1fidt1[/url]

  10. avatar eqjryy86

    <a href="http://www.h8yuex60.com/schwarz-leder-nike-air-max-junior-butya">schwarz leder nike air max junior</a> <a href="http://www.bedkl965.com/nike-lebron-gul-hvit-scarpee">nike lebron gul hvit</a> <a href="http://www.0fn25hbu.com/ua-curry-3-gr%C3%B8n-bl%C3%A5-butyf">ua curry 3 gr酶n bl氓</a> <a href="http://www.ag367vcp.com/herren-nike-zoom-pegasus-32-gold-rot-butyf">herren nike zoom pegasus 32 gold rot</a> <a href="http://www.286zdvwi.com/nike-hyperdunk-2016-low-guld-gr%C3%A5-schuhea">nike hyperdunk 2016 low guld gr氓</a> <a href="http://www.cnvgx2q2.com/billig-jordan-7-chaussuresa">billig jordan 7</a>
    [url=http://www.eqjryy86.com/]eqjryy86[/url]

  11. avatar clojuregames

    <a href="http://www.ibrahimoner.com/ray-ban-sunglasses-4115-mens-sunglassesa">ray ban sunglasses 4115 mens</a> <a href="http://www.quickbeautyhq.com/san-francisco-49ers-tisa-snapback-cap-black-red-hatc">san francisco 49ers tisa snapback cap black red</a> <a href="http://www.epointsclub.com/macy-s-oakley-sunglasses-nose-parts-sunglassesg">macy s oakley sunglasses nose parts</a> <a href="http://www.alaskanuber.com/nike-kwazi-india-price-skox">nike kwazi india price</a> <a href="http://www.ycbrowsbeauty.com/jordan-11-columbian-yellowing-skoc">jordan 11 columbian yellowing</a> <a href="http://www.gfatraining.com/billig-nike-flyknit-lunar-3-dam%C3%A4nner-wei%C3%9F-skob">billig nike flyknit lunar 3 dam盲nner wei脽</a>
    clojuregames http://www.clojuregames.com/

欢迎留言




用户登录

sitemap