简体   繁体   中英

How to post raw json below in the body of retrofit request?

Here I am using retrofit 1.9 and I have to post this json in post request.

{
"note": "",
"amount": "0",
"frequency": null,
"patient": "sameer_998oiib@innotical.com",
"doctor": "",
"date": "2016-04-27",
"reminder": 
[
{
    "days": [2],
    "time": "06:29:00"
}, 
{
    "days": [2, 3],
    "time": "06:30:00"
}
],
"salt": "Abobotulinum Toxin A Injection",
"method": 2,
"unit": 1
   } 

Thanks in advance.

just create an Object like

public class PostObject{
        String note;
        String amount;
        String frequency;
        String patient;
        String doctor;
        String date;
        String salt;
        int method;
        int unit;
        List<Reminder> reminder;

        class Reminder{
            List<Integer> days;
            String time;
        }

    }

and set your request body object

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