2016-05-18 56 views
0

在這裏,我使用的是翻新1.9,我必須在發佈請求中發佈這個json。如何在改裝請求正文中發佈下面的原始json?

{ 
"note": "", 
"amount": "0", 
"frequency": null, 
"patient": "[email protected]", 
"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 
    } 

在此先感謝。

回答

1

剛剛創建像

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; 
     } 

    } 

一個對象,並設置你的請求主體對象

+0

現在怎麼樣,我將值分配給上述的鑰匙? – Arora

+1

用你的值創建PostObject:PostObject object = new PostObject(....) –

+0

我已經創建了這個類的對象,但我無法爲天和時間鍵指定值 – Arora