我是android的新手,我不知道如何在json中发布数据。
{
"LeadId": 1,
"CompanyId": 2,
"Name": "sample string 3",
"CreatedBy": "1",
"IsAgreementGenerated": true,
"CustomerDc": {
"CustomerId": 1,
"AccountNo": "sample string 2",
"FirstName": "sample string 3",
"MiddleName": "sample string 4",
"LastName": "sample string 5",
"CompanyName": "sample string 6",
"CustomerTypeId": 7,
"ContactTypeId": 8,
"SourceId": 10,
"PrimaryEmail": "sample string 11",
"PrimaryPhone": "sample string 13",
"Address1": "sample string 22",
"CountryId": 24,
"StateId": 25,
"CityId": 26,
"Zipcode": "sample string 27",
"CompanyId": 30,
"IsActive": true,
"IsPrimaryBillingAddress": true,
"CreatedBy": true,
"CreatedDate": "2015-12-07T12:51:51.2792695+05:30"
}
}
这是我的json数据如何将这种格式转换成json对象。我想像那样闷死
JSONObject object = new JSONObject();
object.put("LeadId", "1");
object.put("CompanyId", "2");
object.put("Name", "abhishek");
object.put("CreatedBy", "1");
object.put("IsAgreementGenerated", "true");
现在我可以为对象中的下一步做些什么。
答案 0 :(得分:0)
创建customerdc jsonobject并放入对象。
JSONObject customerDcObject = new JSONObject();
customerDcObject.put("CustomerId", "1");
customerDcObject.put("AccountNo", "2");
customerDcObject.put("FirstName", "abhishek");...//add other parameter
object.put("CustomerDc", customerDcObject);