【发布时间】:2018-07-25 18:26:55
【问题描述】:
please tell me I am new to use JSON data. Thanks in Advance.
https://api.myjson.com/bins/waw4y
how to parse this data in android. I am adding the two client details. In that
First, I have added an object for the whole content and after I have added the different client names and age, car with arrays. so please make it as easy.
Thanks in advance
JSON 代表 JavaScript 对象表示法。它是一种独立的数据交换格式,是 XML 的最佳替代品。本章介绍如何解析 JSON 文件并从中提取必要的信息。
Android 提供了四种不同的类来操作 JSON 数据。这些类是 JSONArray、JSONObject、JSONStringer 和 JSONTokenizer。
The first step is to identify the fields in the JSON data in which you are interested in. For example. In the JSON given below we interested in getting
temperature only.
【问题讨论】:
-
stackoverflow.com/questions/2591098/how-to-parse-json-in-java 的可能重复项。请看看它是否可以帮助您解决问题。
-
不,这只是在多个数组中
-
GSON 是来自 Google 的库,它可以帮助您解决您的情况:using GSON
-
数组的数量与解无关。该问题涵盖了将字符串转换为 JSON 的内容。接受的答案告诉您如何从 JSONArray 和 JSONObject 获取值。
-
我检查了你的json,并不复杂。我在 YouTube 视频上使用 github api 做了一个 JSOn 示例。希望这真的对你有帮助。 youtu.be/Pl4dG5FkDfQ