android - Json parsing to get lat long -
i have response google web service follwing
{ "html_attributions" : [], "next_page_token" : "cpqcbgeaalxtlobsfdvixsb8whg4nghrcetbydo0ycgow-ihvfs4cqi1zam331dta8y3cxpezzlf0iyjwqmp2a8w5a5ukttrr4sqq1um6fjguncpzzrct6rwapjkzojbafrpt5gqnqm6w1vxxdk9nku5lybbvlr0yjnzbweaqylyt2mfvak-_qdir8b3yk3efy34ssohnnbnaanvc5hmztz7awgphktdntefusznqq72jpg5_ey5f2g29in_qjxjlr9a3yyngfmeflta2e0t34ogohtvcinrde7dceuuak55lv8tnp33hlgkc7pruxkv4af8xvxnlsk9alvfdzecmj4br6rtq3iwjbz0z5fpnzqjfa6nnfiqehditzbjibr9ceoaefilqjqsghsybib6srfa8b-p86rfbinehjeo3w", "results" : [ { "geometry" : { "location" : { "lat" : 47.610399, "lng" : -122.335791 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "8f7e7d038dbd13f283d1875ecf68d04fc2255561", "name" : "gnc", "opening_hours" : { "open_now" : false }, "place_id" : "chij3zj_hlrqkfqr0axdtprgaji", "price_level" : 2, "reference" : "cnrlaaaaowrgwtpl4nlyi7qpz2ukmxeddwascl5xasmeogpbqsoevbfdxvb2cmywsqz1lr3quydo8djspfkqc0bflka37iw_itw2xrzy4568h5krend1xqvdjzyvmhpawnkkjrtl0bjh_1p1vpg-ntquq-zvkriqdvbtyrun8wsra1eftayo8rouswjcbqkvapwmyljtxfjfk9qmf2i", "scope" : "google", "types" : [ "health", "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "421 pike st, seattle" }, { "geometry" : { "location" : { "lat" : 47.61, "lng" : -122.33 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "82e45a03dca8dcb2192cc250777a11f2e06452de", "name" : "deluxe foods llc", "place_id" : "chij9dkbxbvqkfqrodljese0czo", "reference" : "coqbcwaaad1di5pifx1zh03cyqypsjl10gzc7ufmhekgzvzmibz77zudoxame2ie3wzbgccuuwg3zv735pey9mrlwxdbkbmbgl_mvs_dd6ammnyehwft54gvpabn0zvnlrflneyun-dukoehvx5gewnj1uvygb1zbcy1csuwbiqh4ouay9gpehbhwgut7ycyw9ic3hgguuxgghrhu_ajt-jsrrhxoc6o7ykvpclycg", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "po box 30102, seattle" }, { "geometry" : { "location" : { "lat" : 47.607573, "lng" : -122.333167 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "695bf0d73be3b5f55ca43fe14abce48f9853ef15", "name" : "community grocery", "opening_hours" : { "open_now" : false }, "place_id" : "chijneh4urfqkfqrv3oxahshzxg", "reference" : "coqbcwaaalpg-2ysweiceu-5h5km-syuqelzr70nmsmg9uhs38upusdf4s_5hnf6eq8orgjf7jgv9w9il4cl9to8r0bca7hxk2ghxkrwlbbcp2aspwjtcdzrqb-uus9tkxhc-kldayis9zmlqthodw_j8ssxlzhnhnypol9vjkziuiilpytnehd9a-vcirldcmvzhhnow03fghrsw5ldmdzocvehdrbz2nauhtdz3q", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "415 seneca st, seattle" }, { "geometry" : { "location" : { "lat" : 47.608163, "lng" : -122.335371 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/wine-71.png", "id" : "fde562e2d1e74e8ea18d3f758a05fe78c45d9346", "name" : "essential market", "opening_hours" : { "open_now" : false }, "place_id" : "chijvyqm8lnqkfqrjjm6wicye1a", "rating" : 3.8, "reference" : "coqbcgaaald33oay_-vxbcbf_gmywcqphjyzixfi-yc1glcffxbtptdywxt-vpfknexst7k305ohv0akha_br2eh8aeetn-d7pxuw3mk5vsypubifotrwom_cx2yh84cxoj9efwgxwtiuxeovojhz8syj59n4g78iuudi-mfmgzd_c_jq90rehdj3y45nfvr6ibfvapmnk0zghqdcjyu7zu8ymtuqlgmoesjrtvvgq", "scope" : "google", "types" : [ "liquor_store", "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1301 4th ave, seattle" }, { "geometry" : { "location" : { "lat" : 47.612122, "lng" : -122.332044 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "6b4f8dc7039510bbbfca8fd12b359d444eef2be9", "name" : "clay's market", "place_id" : "chijdxjoe7vqkfqr4odxoxnqeq8", "reference" : "cnrvaaaacc-kzx3pjo0x3ojptam_wqws5kbrk53v4xa6gyioj3pp8fo8l_dqstjkrmqrf8brgvfntktalujzlvxkigj7pnjytaaurpkv0tl7dhpru66cyajrnjorshme0xyhjjnj7vqdell5ho8dab0fzfrevxiq6tzzbeqqrp6qepf_ue7xhbou4y3vkfbscx_4b1pu1aplywxzldq", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "815 pike st, seattle" }, { "geometry" : { "location" : { "lat" : 47.609336, "lng" : -122.337791 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "691548827b64fe2609fb7c27abbb1bcbe224f327", "name" : "kress iga supermarket", "opening_hours" : { "open_now" : false }, "photos" : [ { "height" : 600, "html_attributions" : [], "photo_reference" : "cnrnaaaal-_qcxeqc8uatumrqdzg_bdcp56lf2i2cpbbmxyj71vlemlidrqpc38wmdtwshvoff_pgjlbo4vqhfpjm2nslrpmhqeotyysytwbhocxpf9isdvunjbbyguwcufybdvdcdizachoo0bei5jvzrxnhriqvsyovueat6gfrodcoh95hhous-mac5clzjft12vsx_e7m_vuifi", "width" : 398 } ], "place_id" : "chijbdiholnqkfqrmtihcn6w4nu", "rating" : 4.4, "reference" : "coqbdwaaan3wdcagdfatcilhebd3vwnp0z_zqjq8ninljnqpzhyj2ieg6vegxvfmqcu8bfawcrxo7mtu08gxtelthcypdrqy5kffagdj1dfqi8puh5r7wkkchjgn-spj2cqrsir-k853wjmlnmahzsjmc2xwahlbmy2abxoe_9lspoqfye72ehcobhik_e0gtgpetycfrp6mghslbgpkklzl00qldn6xd44y1tdj7a", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1427 3rd ave, seattle" }, { "geometry" : { "location" : { "lat" : 47.606546, "lng" : -122.335449 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "3f23cf0c8bfdbe746a69d518c031dcafbd266d64", "name" : "netzel associates", "place_id" : "chij1q6vb7fqkfqr0pcosjtlqpm", "reference" : "coqbdaaaabimsr5ilbmkvjterpvavhij7jmxhtacajvz9ytfxvqycp8he5wd4pafaou5dbli4oagjappq8quif9_hyn_ihtkpynhafwqcohshe-6kkio1siie5qdlg-buz2tqkvipmzpqk67x60dgrux31vzjf10dg6bviziimtk5q8d4azwehcjkbwcknurotkkyatmh0jwghs2i7o8ionef9a5_qtbl3n1k8v4fg", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1111 3rd ave # 2500, seattle" }, { "geometry" : { "location" : { "lat" : 47.612607, "lng" : -122.336984 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png", "id" : "1672b9dd46c6dcb5ae1409d0f87b23f1c38f33d0", "name" : "market fresh winter garden", "place_id" : "chijrdhdmksvkfqr0ugnkk-w7fk", "reference" : "coqbfaaaaaxvlhmqlrtabi8g1bbkemysu_pdqmypmkmwnie37krzknukxrqkbpivos7ccb4yxijgz2x79qqw1dtfpj9ee4jclrskmfqzdqzpet1vhcr_imcsiwrlz_51iveuruw8r2gszbwcdislu1ib1gbult58ub8ghs-n3_ygxqae_1jaehbjn_a6kpphjqgq9_pr4aifghqneeknt7jsyb1mvxcdgz4o83anng", "scope" : "google", "types" : [ "meal_takeaway", "restaurant", "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "509 olive way, seattle" }, { "geometry" : { "location" : { "lat" : 47.613069, "lng" : -122.329411 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "08e8916d1ade44b3403b1a1268fc038bd449952b", "name" : "pike grocery", "opening_hours" : { "open_now" : true }, "photos" : [ { "height" : 384, "html_attributions" : [], "photo_reference" : "cnrnaaaamx9yeunwuacoeswmlueyy2zjqt-glprsd0_wxwhv0pp7c42-fvqycfkprodpchiqlzjswa_fpcqadgvai_halfccuhcibbrtejosvlp1ba_acdwmpbdf26vyc6xajqmtr37exiz5j-svyh09_hpezriqap8c87zkuwiyfsr6zsag2rousabkv4fllfmsktthhebvdd0g9vm", "width" : 512 } ], "place_id" : "chijmwdemspqkfqruqq91n-ufeo", "reference" : "cnrvaaaapcluek8vrv5wcsbp4g08nttaphmkftasuhtar4i8vuntfksp7np06jc4y3xj7qtr9i105d7hpvkqjhuh6hdylzej-fm5ydc7lqnmmkran3ccmqezcd9mhszkdxdtdktsyazv4ggwogi4lqfcugfhdbiqd1m7sq4-ewj4y6cnujpkhbounhovxfwyl3lk7imaxjkxgkknh9k", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1011 pike st, seattle" }, { "geometry" : { "location" : { "lat" : 47.606521, "lng" : -122.337704 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "110c00b34dc635662716772ab4a0e0f6deced28a", "name" : "young's market", "place_id" : "chij44qiilfqkfqrw1tsxz9h2kg", "reference" : "cnrwaaaaxmdsj6fxuip8s9c42j9nsu7xtmyny612ts6njqubsozlbjwpr6gmxsrrkrepttltbsywomq4gp2ovwo2utvqtlpjhcws2ycfhnkj4k8sz7f_d3aoazownkmip88bpxmbpujj9eki5gvtxct9cfre4biqoltwxcaybhklutmnfvgnfhoulo1jmn7wrjubvbcnzye5qubtl_w", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1210 1st ave, seattle" }, { "geometry" : { "location" : { "lat" : 47.608777, "lng" : -122.33973 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "d2f9218e208a84da7c7a7e2980cebd3671a8f386", "name" : "double dorjee", "place_id" : "chijkx3s-ljqkfqrqrexqcn0jqy", "reference" : "cnrvaaaaordvxz8w_qmewpmjxxulaz9ls562rrqgirkeihgxesloxngcjsw2iqiymeukrmvqwraoulyroia8t1ypqdyyaveajqixcz0pwzmeueaduckl37p_wgzkojuhhv0ki_3z10bopwmcnvo5xiofz7j1abiqk9udmy_ktiytp8tnog5t_roulyeozrnbyy8eulqd7lugs_e7kru", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1501 pike st, seattle" }, { "geometry" : { "location" : { "lat" : 47.608248, "lng" : -122.339523 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "efeff82fc657a72cf8a3079aabe0e27d0d91a6c5", "name" : "lina's fruit & produce", "place_id" : "chijd22j-ljqkfqrxheagumcphs", "reference" : "coqbeaaaafcdpyes7w9sdbbhp_boynqrm1cuqichslnr-hyxateywmptknieds27q0hr5blfqazqvgp_yim2eldrfsjtsdtvgijlwzuvhtsbridv4n8cthl6uihzjnmtevrbyrq7geid2bp_izilj4k6nyipsykljnpbbvckasbesn4tatm-ehcyse2fgypwegx4zhaku6t7ghs2-n0cgphzmvmagnmkyp2gcw23-g", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1431 1st ave # 7, seattle" }, { "geometry" : { "location" : { "lat" : 47.605109, "lng" : -122.333955 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "d81b188da1c901ec10149c5224e6fd1beac9ef9c", "name" : "second avenue sundries", "place_id" : "chijexg9_rbqkfqri7zb8km4p98", "reference" : "coqbeqaaaoh07x4jtyj3wta6swnshxcpgitpl7kbsjbqfref2vuj-vxjenchmiogcvsireyesv_dzyyxg3rompezucukuivlsaet1wxjck6t0tm8qhyltdcc9ijrmje_npy9rtbiehbixa5esv1egmf_rhyhqjyhpjaz7hmdcdlysebruyssehaq3ulvuena0ac8l59q8zefghsurfu9dmukkl24sq6rmqva74mb5w", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "999 3rd ave, seattle" }, { "geometry" : { "location" : { "lat" : 47.614062, "lng" : -122.335451 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "69ff94699431b37223bdea4fd7792c7244a6b36c", "name" : "sphere foods", "place_id" : "chij1ef53eovkfqrlyzowpy7dha", "reference" : "cnruaaaa6qjcwzs9h_eb5x5uoan2j99lisj9nevr-ltbjuolkx5ojmlmggyeazqmbf02rp8trqyevee41rhimdgdvnqkj5wblrxqcvm195y3blssymy7kutfvaiclgzjvdepf5wlcc9xl6jjfiwxqn-5i1oeihiqztgmyrh317g1c7rrqwd9mxoumsfftx5fwgeczfdh7hrfx4f5mja", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1700 7th ave # 2100, seattle" }, { "geometry" : { "location" : { "lat" : 47.614425, "lng" : -122.334307 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png", "id" : "e5be7cde6eb52cb0a5a7aa975ea915e2f80bd7dc", "name" : "stewart street market", "opening_hours" : { "open_now" : true }, "photos" : [ { "height" : 1152, "html_attributions" : [], "photo_reference" : "cnrnaaaaqezqn6galgijib2wanacw7gdnljucc6avrmcf543gbpl9tglj99cs0dmrdbhywvmcw_h7q_lzgoqqklwkilb95sjxsjqu4o3kmvqqaqtqwhw27u2vkvktoqxawtdppdmanopmulfp2lln1zya33z2xiqy-si5ntvqw9cptd2ahp9nxourwp9wssgmzy2dtc1q6oeznsuvqw", "width" : 2048 } ], "place_id" : "chij7ybfx0ovkfqrcljvxnf_3qg", "reference" : "coqbeaaaadtkepb503o9qn93lxgtilh8x-uyigris0pj_-ggxpxqoqkanigcmvygdlezcftpgzdchjxrwmns1rpuhqnthnjp4_vmg3zp42zfndao_q2_yowpim7wgz3oqsr66uiebkznnw9qrrd_gmba64odlzgrn7wzwvdp5uwccnjje0nfehbkdwgnlhztu2y4boi6zl-lghsbbds4npetalx_cwgpmtmkupp43g", "scope" : "google", "types" : [ "convenience_store", "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1812 8th ave, seattle" }, { "geometry" : { "location" : { "lat" : 47.609322, "lng" : -122.325655 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "87b467979468e6d2b5b203c7486d84e08505dd17", "name" : "plaza select foods", "photos" : [ { "height" : 720, "html_attributions" : [ "from google user" ], "photo_reference" : "cnrnaaaahzdjbafparrh7mlsub87bvza6erjkrsvynku6pga1ecblihzmqnx67hzqog-eo7wkvag7kp0bnxwvnxo9rf5u2vynxzz-5v7z7khl7tomfwi7u7n6afr9sls_fz_kcpbmh-m63nl4h6e5gdfzwwnuxiqjuhogatxdda9yt62kvkejhouvenpqc8obghyjowtpijdxsf2ah8", "width" : 960 } ], "place_id" : "chijy1bfh7zqkfqrxpkoz2nfh2y", "reference" : "coqbdaaaajz0wnou_progj7t62fbe2adox6sggh0yir1kngrqiz9scwkjbjmhuhb3vnkzzeuvfuibpojrfbtkbjpeuthcc8hhbe_hsulcyp2fui2afdvgbwb49x4fpla0icnooecfezwrskswckgcnyob1wt_mb2neebqvfdr8w6vhrsl1eyehbgagq9wxqzlhzzzrs84jeyghrm0rx5tif0g11uft5mg6v6uhr97g", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1024 madison st, seattle" }, { "geometry" : { "location" : { "lat" : 47.608802, "lng" : -122.340552 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "14a2e0601f06734e7c8be82ed00d3806e3f9ecd4", "name" : "corner produce", "place_id" : "chijn9fr9rjqkfqr89xobvdunbe", "reference" : "cnrwaaaafad6cccaww55vmsdqvh9xczzhx5loyfh2mht5ykfm9nznr7l3ekhd02_vnseunz3smlcyvt37k-tg6ezv4muwvoz2imbvrpx1oergjws6ogxx-fhabcaj2w5jgrkcshwehjwtw0dnyndx5gen-a1hriqnscen53q1pc3nahctutgarou-4qq8zofjff3lyyc1xf66fn8kq0", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1500 pike pl, seattle" }, { "geometry" : { "location" : { "lat" : 47.60884, "lng" : -122.340616 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png", "id" : "2a7a890254bcb2b1ae409cbf78d4e741800f036f", "name" : "oriental mart", "photos" : [ { "height" : 460, "html_attributions" : [ "\u003ca href=\"https://plus.google.com/115115924044576716973\"\u003ematt good\u003c/a\u003e" ], "photo_reference" : "cnrtaaaayab-xnz1tm-iib1qfxzjic-t--li7mr5har62p-rlgtraiapk2lhwogwotqcfjpihcim2ayn2iu-qkqpvgsegony955zdeo6t3ooukgnvt5wzvw6w_wu3andylnh0xh-wri4tni6t70jutwps6qkrriqbdkblq6yk1rolxynfsyf0boun9chrbamj73djleiqezjxmi-9ny", "width" : 816 } ], "place_id" : "chijt7fx9rjqkfqr-r2iorwxyxq", "reference" : "cnrvaaaa8b_d2xlfyevl6oi5uygrdjilg6dw3orrlu8q9xd9eukh2omatgnlupkgahjjren5jinkdj9fsmpr4f0du2xmbw9xmmepo6cmpeg8zbbhqvnbs2zhzu2_m0wfnlv21mdxfad20gvx6f6cdz2cokb_khiqhh6kz-vny430yf0evmh7ebouz3tvjq_rhxxly_jpan1qk2yc3um", "scope" : "google", "types" : [ "convenience_store", "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1506 pike pl #509, seattle" }, { "geometry" : { "location" : { "lat" : 47.608918, "lng" : -122.340729 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "301d23a6579067833036e39ef46357e1d8e5ba68", "name" : "frank's quality produce", "place_id" : "chijpdhb8ljqkfqro8x7roxoz2u", "reference" : "coqbeqaaakebhfrm9opub4cwc5bc1hyamxofc0lzwywcx-4eyhtooievcxhisj4y1xkbixtisttpetjynr5kkux3y3q5zf7skuttqirybk0hesohet1_edcnpu31_ibrlo9w-t_7widb3fnn24rymz9j9kz7pxhlykyr2vlmutlmalnljc2yehchddy463zp0hrizaasfsg3ghte1n0deejjdnxnb2ak4zof1hgkmw", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1508 pike pl, seattle" }, { "geometry" : { "location" : { "lat" : 47.609231, "lng" : -122.340848 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png", "id" : "228c792a04f0d9c3b8086b9f857521945f87c975", "name" : "choice produce", "place_id" : "chijmbby97jqkfqr4jkukxvdt3a", "reference" : "cnrwaaaawe1ak6eoe-rdrjgs2hjzhb__vicdwu2u7qx0chme1cgdnnoycw_dcim98szb2bzujty12wgk9fgo42jpywl-zevm_ilfqi6q7jvrqxsgvsybbzau_tc_orgj41gz8fwk1r6_yvat1n0ii9dpfca1lxiqvirixzwl3grqyk3dun_4zrourndpghpgzhkunggpibllh46zoqi", "scope" : "google", "types" : [ "grocery_or_supermarket", "food", "store", "establishment" ], "vicinity" : "1514 pike pl, seattle" } ], "status" : "ok" }
i need parse , lat , long values
i have assigned this
jsonarray ja=new jsonarray(result); jsonobject json= null;
where result contains web service response. how can parse , required values?
cast response jsonobject this
jsonobject jsonobj = new jsonobject(result);// result response got
get result array this
jsonarray results = jsonobj.getjsonarray("results"); // results tag in resposne
now have entire array in results loop entire stuff
for(int i=0;i<results.length();i++) { jsonobject location = results.getjsonobject(i).getjsonobject("geometry").getjsonobject("location");; string lat = location.optstring("lat"); string lng = location.optstring("lng"); }
if need lat , long within array, add together array.
android json
No comments:
Post a Comment