简体   繁体   中英

Get PHP JSON Data in Android

I do alot of development in PHP. And I have recently started working with JSON data for various APIs for my websites to interact with each other. I would like to extend this a little further and create a Android app with my web applications.

Please keep in mind I am fairly new at Android and have little experience. I have worked with JSON data in JavaScript, and it is fairly easy. However that is using jquerys easy to use Ajax .post.

So my question is, what is the easiest, most simple way to get JSON data from a website and turn it into a working variable in Android?

I would prefer something with no error checking or anything. Just the basics.

Thanks!

If you're programming object oriented, there is not any easier way then to do it with JSON, so this is a good choice.

You can use Google's Gson to parse the Json strings your PHP back-end sends to your Android app.

As long as you use Objects, you can parse the string into an object with 1 line of code. Just be sure to type all fields correctly on your PHP side.

Take a look at this tutorial , I used this a while back and it makes it pretty clear :)

As @alexander7567 mentioned, GSON is also very good to use. But may be a bit more complex for you to pick up at first!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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