我想將所有下面的對象作爲單個對象遞歸合併。每次我爲每次迭代運行代碼時,都會收到一個字符串對象,我將它們存儲在一個列表中。列表如下所示:將下面的值作爲單個值合併到列表中
bean [String1,String2,String3]。這三個字符串將被合併爲一個字符串對象。
字符串1:
[code=100,
response=
{
"testObjects": [
{
"updated": [
{
"attributes": {},
"id": "123"
},
{
"attributes": {},
"id": "456"
}
],
"timeCheckQuery": null,
"query": null,
"message": null,
"error": null,
"deleted": null,
"agentId": null,
"added": null
}
],
"message": null,
"error": null
}
]
String2的:
[code=100,
response=
{
"testObjects": [
{
"updated": [
{
"attributes": {},
"id": "789"
},
{
"attributes": {},
"id": "759"
}
],
"timeCheckQuery": null,
"query": null,
"message": null,
"error": null,
"deleted": null,
"agentId": null,
"added": null
}
],
"message": null,
"error": null
}
]
STRING3:
[code=100,
response=
{
"testObjects": [
{
"updated": [
{
"attributes": {},
"id": "242"
},
{
"attributes": {},
"id": "951"
}
],
"timeCheckQuery": null,
"query": null,
"message": null,
"error": null,
"deleted": null,
"agentId": null,
"added": null
}
],
"message": null,
"error": null
}
]
輸出:
[code=300,
response=
{
"testObjects": [
{
"updated": [
{
"attributes": {},
"id": "123"
},
{
"attributes": {},
"id": "456"
},
{
"attributes": {},
"id": "789"
},
{
"attributes": {},
"id": "759"
},
{
"attributes": {},
"id": "242"
},
{
"attributes": {},
"id": "951"
}
],
"timeCheckQuery": null,
"query": null,
"message": null,
"error": null,
"deleted": null,
"agentId": null,
"added": null
}
],
"message": null,
"error": null
}
]
可能的重複http://stackoverflow.com/questions/1751844/java-convert-liststring-to-a-string – Kagemusha