如何遍历Java列表数组将对象键值对保存到自己的数组
我想看看是否有可能获取对象的Java列表数组,搜索对象的键值对,并将它们保存到自己的数组中
带有对象的数组
[
{
"applicationUserSubscriptionUniqueId": 18639,
"createdByName": "2222",
"updatedDate": "2019-12-02T19:17:45.000+0000",
"applicationsSupported": {
"appSupportedId": 5,
"supportAreaId": 123,
"supportAreas": {
"applicationId": 123,
},
"appSupportedName": "app1"
},
"userSubscriptionInformation": {
"userSubscribedUniqueId": 18638,
},
"reportSubscriptionId": 18638,
},
{
"applicationUserSubscriptionUniqueId": 18638,
"createdByName": "2222",
"updatedDate": "2019-12-02T19:17:45.000+0000",
"applicationsSupported": {
"appSupportedId": 6,
"supportAreaId": 123,
"supportAreas": {
"applicationId": 123,
},
"appSupportedName": "app2"
},
"userSubscriptionInformation": {
"userSubscribedUniqueId": 18638,
},
"reportSubscriptionId": 18638,
},
{
"applicationUserSubscriptionUniqueId": 18637,
"createdByName": "2222",
"updatedDate": "2019-12-02T19:17:45.000+0000",
"applicationsSupported": {
"appSupportedId": 15,
"supportAreaId": 123,
"supportAreas": {
"applicationId": 123,
},
"appSupportedName": "app3"
},
"userSubscriptionInformation": {
"userSubscribedUniqueId": 18638,
},
"reportSubscriptionId": 18638,
},
]
代码
public List<ApplicationUserSubscription> findEmailTest() {
int appId = 1;
List<ApplicationUserSubscription> myList =
applicationUserSubscriptionRepository.findUsersEmailSubscribedToApplication(appId);
System.out.println(myList);
假设我想遍历这个数组,并将所有“appSupportedId”保存到它自己的数组中
NewArray[]=myList。appSupportedId
任何建议或帮助都将不胜感激,谢谢
# 1 楼答案
假设使用的对象具有以下字段,则可以尝试此操作
如果是
Map
,那么你可以试试