How does Android submit JSON format data through retrofit

This article describes how to post a string of JSON formatted data through the retrofit library. First, the JSON data format of post is as follows:

By installing the Android studio gsonformat plug-in, a bean class is automatically generated according to the JSON format above, which is named flyroutebean in this paper,

Then we will establish the interface, which is as follows:

The next step is to submit data:

< ---------------- update how to submit JSON data and other query fields at the same time: ---------------- >

Server side (ASP): the core code is as follows: receive a JSON format student class and add a bool type

client:

Implementation code:

result:

The specific code has been transferred to GitHub

PS: the servers in this article are built by the landlord on the LAN,

Dependencies to add:

compile 'com.squareup.retrofit2:retrofit:2.0.2' compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'

Source code download

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>