如何在android应用程序中解析、序列化和反序列化大JSON数据?
我有一个来自服务器的大JSON数据,我必须对它进行解析,并使其成为与图片类似的android应用程序 我不知道该怎么做 以下是我的JSON响应:如何在android应用程序中解析、序列化和反序列化大JSON数据?,android,json,rest,api,bigdata,Android,Json,Rest,Api,Bigdata,我有一个来自服务器的大JSON数据,我必须对它进行解析,并使其成为与图片类似的android应用程序 我不知道该怎么做 以下是我的JSON响应: [ { "PatientID": 61270, "ItemId": 113883, "InvoiceID": 199223, "ReceiptId": null, "PatientAdmissionId": null, "NurseStationId": null, "ServiceListPr
[
{
"PatientID": 61270,
"ItemId": 113883,
"InvoiceID": 199223,
"ReceiptId": null,
"PatientAdmissionId": null,
"NurseStationId": null,
"ServiceListPrice": 800.00,
"ServiceActualPrice": 800.00,
"ServiceQuantity": 1,
"ServiceDate": "/Date(1573464484000)/",
"ReferralPaidDate": null,
"ModifiedDate": null,
"CheckoutTime": null,
"ServiceProviderId": 40576,
"DoctorId": 40576,
"DoctorName": "Md. Shahed Ashraf",
"ReturnQantity": null,
"ReturnPrice": null,
"ReturnPaid": 0.00,
"ReferrerPaidUserId": null,
"ReferrerPaidUser": null,
"Discount": 0.00,
"DiscountAfterInvoice": false,
"IsBothSideDiscount": true,
"DiscountPercentage": 0,
"Refund": false,
"RefundApprovedBy": null,
"RefundStatus": 101,
"RefundApproval": false,
"IsReturn": false,
"RefundNote": "Test2",
"Billed": true,
"ReferralFee": 320.00,
"ReferralFeePaid": false,
"ReferralFeeActual": 320.00,
"DeliveryDate": "/Date(1573495200000)/",
"DeliveryTime": null,
"ReportFormatName": null,
"LabStatusId": 1,
"InventoryId": null,
"ModifiedBy": 30253,
"PrescriptionItemId": null,
"Item": {
"Name": "RA",
"GenericName": null,
"Code": "0184",
"CompanyName": null,
"ItemTypeId": 32,
"MedicalTypeId": 62,
"ItemSpecimentId": 15,
"ItemCategoryId": 50440,
"ItemSubCategoryId": null,
"ItemGroupCategoryId": null,
"ItemSubGroupCategoryId": null,
"SupplierOrVendorId": null,
"Strength": null,
"Formulation": null,
"IsAntibiotic": false,
"MedicineTypeId": null,
"IsSurgeryItem": false,
"MeasurementUnitId": null,
"SalePrice": 800.00,
"BuyPrice": 0,
"ServiceProviderId": null,
"ReferralAllowed": true,
"Description": null,
"DefaultReferrarFee": 320.00,
"LabReportGroupId": 73,
"NurseStationId": null,
"NurseStation": null,
"TaskTypeId": 101,
"TaskType": null,
"LabCountDay": 1,
"IsLabReportItem": false,
"CreatedDate": null,
"BedOccupancies": [],
"Inventories": [],
"Item_ItemGroup": [],
"ItemDefaults": [],
"ItemReorders": [],
"InitialSetupItems": [],
"ServiceProviderSurgeryPrices": [],
"ItemType": null,
"ItemSpeciment": {
"Name": "Blood",
"MedicalTypeId": 62,
"Items": [],
"MedicalType": null,
"TenantId": 16,
"Tenant": null,
"Id": 15,
"Active": true,
"UserId": 30254,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"ItemCategory": {
"Name": "Serology",
"MedicalTypeId": 62,
"ReferralCommission": 40,
"Items": [],
"ItemSubCategories": [],
"MedicalType": null,
"TenantId": 16,
"Tenant": null,
"Id": 50440,
"Active": true,
"UserId": 30254,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"ItemSubCategory": null,
"ItemGroupCategory": null,
"ItemSubGroupCategory": null,
"MedicineType": null,
"MeasurementUnit": null,
"MedicalType": null,
"ServiceProvider": null,
"LabReportGroup": {
"Name": "Serology",
"Items": [],
"BranchId": 0,
"Branch": null,
"TenantId": 16,
"Tenant": null,
"Id": 73,
"Active": true,
"UserId": 30254,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"SupplierOrVendor": null,
"PatientServices": [],
"ReceiptPayments": [],
"InventoryItem": [],
"ItemRequisition": [],
"ExpiryDate": "N/A",
"Inventory": null,
"Quantity": 0,
"PrescriptionItemId": null,
"BranchId": 0,
"Branch": null,
"TenantId": 16,
"Tenant": null,
"Id": 113883,
"Active": true,
"UserId": 30254,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"Inventory": null,
"User": null,
"Patient": {
"OldId": null,
"FirstName": "MD",
"LastName": "Pannu",
"PhoneNumber": "01728621378",
"GenderId": 1,
"BloodGroup": null,
"BloodGroupId": null,
"FatherName": null,
"DOB": "/Date(221335200000)/",
"NationalId": "",
"Occupation": null,
"Street": "Elephentroad",
"City": "Dhaka",
"Zip": "",
"Country": "BD",
"Email": "",
"Photo": "bfa0f55f-f016-490c-9191-cdc7568392a0.jpg",
"EmergencyNumber": "",
"EmergencyContactName": "",
"EmergencyContactRelation": "",
"CreatedDate": "/Date(1546768262430)/",
"Gender": {
"Name": "Male",
"Code": 101,
"TypeName": "Male",
"User": null,
"BloodDonors": [],
"Id": 1,
"Active": true,
"UserId": 2,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"Memberships": [],
"PatientInvoices": [],
"PatientServices": [],
"Payments": [],
"DoctorAppointments": [],
"TenantId": 16,
"Tenant": null,
"Id": 61270,
"Active": true,
"UserId": null,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"PatientInvoice": null,
"ServiceProvider": {
"ContactId": 71088,
"Title": "Dr.",
"ServiceProviderTypeId": 56,
"NurseStationId": null,
"DepartmentId": 425,
"Degree": "MBBS (CU), BCS (Health)",
"Speciality": "",
"Description": "null",
"Code": "",
"AssignedToAllUsers": true,
"IsInHouse": true,
"IsReferer": true,
"Designation": "Asst. Prof.",
"HasSigningPermission": false,
"IsSurgeon": false,
"JoiningDate": null,
"CreatedDate": null,
"Contact": {
"FirstName": "Md. Shahed",
"LastName": "Ashraf",
"PhoneNumber": "01711319123",
"GenderId": 1,
"Street": "",
"City": "",
"Zip": "",
"Country": "BD",
"Email": "",
"Fax": "",
"WebSite": "null",
"Photo": "null",
"IsCompany": null,
"ServiceProviders": [],
"ServiceProviderType": 56,
"Gender": {
"Name": "Male",
"Code": 101,
"TypeName": "Male",
"User": null,
"BloodDonors": [],
"Id": 1,
"Active": true,
"UserId": 2,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"TenantId": 16,
"Tenant": null,
"Id": 71088,
"Active": true,
"UserId": 30254,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"Department": {
"Name": "Medicine",
"ServiceProviders": [],
"TenantId": 16,
"Tenant": null,
"Id": 425,
"Active": true,
"UserId": 30253,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"Items": [],
"PatientAdmissions": [],
"NurseStationInchargeList": [],
"ServiceProviderType": {
"Name": "Doctor",
"ServiceProviders": [],
"LanguageCode": null,
"Id": 56,
"Active": true,
"UserId": null,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"DepartmentName": null,
"ReferralFee": 0,
"BranchId": 25,
"Branch": {
"Name": "Main",
"IsMainBranch": false,
"TenantId": 16,
"Tenant": {
"Name": "mobileapp",
"Url": "mobileapp",
"Id": 16,
"Active": true,
"UserId": 2,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"Id": 25,
"Active": true,
"UserId": 2,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"TenantId": 16,
"Tenant": null,
"Id": 40576,
"Active": true,
"UserId": null,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"PrescriptionItem": null,
"Doctor": {
"ContactId": 71088,
"Title": "Dr.",
"ServiceProviderTypeId": 56,
"NurseStationId": null,
"DepartmentId": 425,
"Degree": "MBBS (CU), BCS (Health)",
"Speciality": "",
"Description": "null",
"Code": "",
"AssignedToAllUsers": true,
"IsInHouse": true,
"IsReferer": true,
"Designation": "Asst. Prof.",
"HasSigningPermission": false,
"IsSurgeon": false,
"JoiningDate": null,
"CreatedDate": null,
"Contact": {
"FirstName": "Md. Shahed",
"LastName": "Ashraf",
"PhoneNumber": "01711319123",
"GenderId": 1,
"Street": "",
"City": "",
"Zip": "",
"Country": "BD",
"Email": "",
"Fax": "",
"WebSite": "null",
"Photo": "null",
"IsCompany": null,
"ServiceProviders": [],
"ServiceProviderType": 56,
"Gender": {
"Name": "Male",
"Code": 101,
"TypeName": "Male",
"User": null,
"BloodDonors": [],
"Id": 1,
"Active": true,
"UserId": 2,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"TenantId": 16,
"Tenant": null,
"Id": 71088,
"Active": true,
"UserId": 30254,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"Department": {
"Name": "Medicine",
"ServiceProviders": [],
"TenantId": 16,
"Tenant": null,
"Id": 425,
"Active": true,
"UserId": 30253,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"Items": [],
"PatientAdmissions": [],
"NurseStationInchargeList": [],
"ServiceProviderType": {
"Name": "Doctor",
"ServiceProviders": [],
"LanguageCode": null,
"Id": 56,
"Active": true,
"UserId": null,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"DepartmentName": null,
"ReferralFee": 0,
"BranchId": 25,
"Branch": {
"Name": "Main",
"IsMainBranch": false,
"TenantId": 16,
"Tenant": {
"Name": "mobileapp",
"Url": "mobileapp",
"Id": 16,
"Active": true,
"UserId": 2,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"Id": 25,
"Active": true,
"UserId": 2,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"TenantId": 16,
"Tenant": null,
"Id": 40576,
"Active": true,
"UserId": null,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
},
"NurseStation": null,
"ReceiptPayment": null,
"PatientAdmission": null,
"Isgroup": false,
"PatientServiceIds": null,
"GroupItemIds": null,
"MedicalTypeId": 0,
"BeforeReturnPrice": 0,
"ReturnBackupPrice": 0,
"FullReturnServiceListPrice": 0,
"BranchId": 25,
"Branch": null,
"TenantId": 16,
"Tenant": null,
"Id": 218017,
"Active": true,
"UserId": 30253,
"HasErrors": false,
"ErrorCount": 0,
"NoErrors": true
}
]
正如你在图片中看到的,我必须解析它,并使其成为与图片类似的android应用程序
现在我该怎么做呢?检查这个
var jsonObj = jsonArr.optJSONObject(0)
var firstName = jsonObj.optJSONObject("Patient").optString("FirstName")
var lastName = jsonObj.optJSONObject("Patient").optString("LastName")
var itemName=jsonObj.optJSONObject("Item").optString("Name")
var categoryName=jsonObj.optJSONObject("Item").optJSONObject("ItemCategory").optString("Name")
var patientID=jsonObj.optString("PatientID")
var patientName = firstName + lastName
“格式化”是什么意思?也许你的意思是你想解析它?你是对所有的信息感兴趣还是仅仅对其中的一个子集感兴趣?有一些在线工具可以用来生成与GSON一起工作的POJO。您所说的格式到底是什么意思,以及您为什么需要它?@PPartisan我不需要所有信息,我只需要其中的一个子集。你可以看到这幅画。