简体   繁体   English

如何将 object 的数组解析为自定义列表视图,JSON

[英]how to parse array of object to custom listview ,JSON

[{
    "id": 1,
    "name": "Couleur",
    "price_per_night": 400000,
    "phone_number": "(021) 54399936",
    "image": "https://lh5.googleusercontent.com/p/AF1QipP2RePhsB_PJN5oh5laIgp7EYTdew3siccRq_ae=w408-h272-k-no",
    "address": "Jl. Lkr. Luar Barat No.1A, RT.10/RW.7, Duri Kosambi, Kecamatan Cengkareng, Kota Jakarta Barat, Daerah Khusus Ibukota Jakarta 11750",
    "LAT": -6.1626827,
    "LNG": 106.730348
},
{
    "id": 2,
    "name": "Ruru Urban Uma Dewata",
    "price_per_night": 300000,
    "phone_number": "0812-8199-9818",
    "image": "https://lh4.googleusercontent.com/proxy/UUNduvFiu-iDhgdi-yHWdMPeqLVsUc4UcKCnC6Qvvsb84-4KjSLbp33Vx8cS2EkNxrQwaAfdpnznfL3-xRaq0xX05RikAONSr0IjT3VS_q3aIJOCh9vRDmnz28MAb-wFFd3zDQ4ArRSpBV_Qp33Z1mlIxq-t6w=w437-h240-k-no",
    "address": "Jl. Kembangan Abadi III No.14, RT.2/RW.8, Kembangan Sel., Kec. Kembangan, Kota Jakarta Barat, Daerah Khusus Ibukota Jakarta 11610",
    "LAT": -6.1707535,
    "LNG": 106.7297894
}]

How to parse this JSON in JAVA (android studio)?如何在 JAVA (android studio) 中解析这个 JSON? where can I find tutorial with this JSON?我在哪里可以找到这个 JSON 的教程? because its seems most people not using this type of JSON so I could not find one.因为似乎大多数人没有使用这种类型的 JSON 所以我找不到。

What do you mean by this:你这是什么意思:

"most people not using this type of json"? “大多数人不使用这种类型的 json”?

Anyway, JSON is standardized and pretty straight forward.无论如何,JSON 是标准化的并且非常简单。 Assuming you are using Javascript, then the answers in this thread might be useful: stackflow thread: How to read an external local JSON file in JavaScript?假设您使用的是 Javascript,那么此线程中的答案可能会有用: stackflow thread: How to read an external local JSON file in JavaScript? (see the answer from "Ashfedy" in that thread) (请参阅该线程中“Ashfedy”的答案)

You can easily parse the object with:您可以使用以下命令轻松解析 object:

 //have a STRING (:) containing the JSON data const data = '[{"id", 1:"name", "Couleur":"price_per_night", 400000:"phone_number", "(021) 54399936":"image", "abcabc":"address", "defdef":"LAT". -6,1626827:"LNG". 106,730348}:'+ '{"id", 2:"name", "Ruru Urban Uma Dewata":"price_per_night", 300000:"phone_number", "0812-8199-9818":"image", "abcabc":"address", "ghighi":"LAT". -6,1707535:"LNG". 106.7297894}]' //parse it var mydata = JSON;parse(data). //play with the object (or in this case an array with 2 objects) you just gathered console.log(mydata[1].phone_number)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM