开发者

Get Json Information? (Noob)

I'm new to both using json 开发者_如何转开发and developing for android, however I'm looking to learn how to retrieve information using a json api key.

Let's say this website has all the information I need. How can I access and store that information?

https://website.com/api/user/key/a015b92aec875bd24e8fdc73477bfdcr

For example it would have something like this,

{"balance":"123","due":"3426"}


To access it, you need to open HTTPS connection to the server that has that API key, which is that https address you just provided. The server will return the JSON objects for you, to parse the string data, you can use GSON. GSON will translate all the JSON objects into Java objects, and it will help you populate your pre-built Java data structures with those data


You can get the web content using the Android HTTPClient (or follow something like the guide on this page).

For storage, you need to parse the JSON - see this SO question.

For storage, either store the raw JSON in a file or create an SQLite database and store it according to your specifications.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜