急急急!!!gson 解析不规则数组!!! 5C

[
{
"type": "groups",
"namespace": "groups:1",
"householdId": "Sonos_0C8nr0lan5l5YuRfkJHTbrvq4D.ToP-I1dRlG8VTpyz5MBS"
},
{
"groups": [
{
"id": "RINCON_7BHBFF96BF5A34300", // PlayroomPlayerIdGroupId
"name": "Playroom",
"coordinatorId": "RINCON_8HJLQE01RW4B21097", // PlayroomPlayerId
"playbackState": "PLAYBACK_STATE_IDLE",
"playerIds": [
"RINCON_8HJLQE01RW4B21097" // PlayroomPlayerId
]
},
{
"id": "RINCON_A8E9677G21B091499", // MasterBRPlayerIdGroupId
"name": "Master Bedroom + 1",
"coordinatorId": "RINCON_Y6C3211GJ59H88131", // MasterBRPlayerId
"playbackState": "PLAYBACK_STATE_IDLE",
"playerIds": [
"RINCON_Y6C3211GJ59H88131", // MasterBRPlayerId
"RINCON_B8E9377C21G061890" // BackPorchPlayerId
]
},
{
"id": "RINCON_Z4H7803J17K741322", // FamilyRoomPlayerIdGroupId
"name": "Family Room + 2",
"coordinatorId": "RINCON_D7Y5432M12H127890", // FamilyRoomPlayerId
"playbackState": "PLAYBACK_STATE_IDLE",
"playerIds": [
"RINCON_A4E9395C21G061898", // KitchenPlayerId
"RINCON_C4T1256L09Q293216", // SunRoomPlayerId
"RINCON_D7Y5432M12H127890" // FamilyRoomPlayerId
]
},
],
"players": [
{
"id": "RINCON_8HJLQE01RW4B21097", // PlayroomPlayerId
"name": "Playroom",
"icon": "playroom",
"websocketUrl": "wss://192.168.55.135:1443/websocket/api",
"restUrl": "https://192.168.55.135:1443/api",
"softwareVersion": "38.5-43170-DevPreview",
"deviceIds": [
"RINCON_8HJLQE01RW4B21097" // PlayroomPlayerId
],
"apiVersion": "1.0.0-DevPreview+1234",
"minApiVersion": "1.0.0"
},
{
"id": "RINCON_Y6C3211GJ59H88131", // MasterBRPlayerId
"name": "Master Bedroom",
"icon": "masterbedroom",
"websocketUrl": "wss://192.168.55.176:1443/websocket/api",
"restUrl": "https://192.168.55.176:1443/api",
"softwareVersion": "38.5-43170-DevPreview",
"deviceIds": [
"RINCON_Y6C3211GJ59H88131" // MasterBRPlayerId
],
"apiVersion": "1.0.0-DevPreview+1234",
"minApiVersion": "1.0.0"
},
{
"id": "RINCON_B8E9377C21G061890", // BackPorchPlayerId
"name": "Back Porch",
"icon": "livingroom",
"websocketUrl": "wss://192.168.55.244:1443/websocket/api",
"restUrl": "https://192.168.55.244:1443/api",
"softwareVersion": "38.5-43170-DevPreview",
"deviceIds": [
"RINCON_B8E9377C21G061890" // BackPorchPlayerId
],
"apiVersion": "1.0.0-DevPreview+1234",
"minApiVersion": "1.0.0"
},
{
"id": "RINCON_A4E9395C21G061898", // KitchenPlayerId
"name": "Kitchen",
"icon": "kitchen",
"websocketUrl": "wss://192.168.55.241:1443/websocket/api",
"restUrl": "https://192.168.55.241:1443/api",
"softwareVersion": "38.5-43170-DevPreview",
"deviceIds": [
"RINCON_A4E9395C21G061898", // KitchenPlayerId
"RINCON_B5R0432H68L104369" // KitchenRightPlayerId
],
"apiVersion": "1.0.0-DevPreview+1234",
"minApiVersion": "1.0.0"
},
{
"id": "RINCON_C4T1256L09Q293216", // SunRoomPlayerId
"name": "Sun Room",
"icon": "kitchen",
"websocketUrl": "wss://192.168.55.187:1443/websocket/api",
"restUrl": "https://192.168.55.187:1443/api",
"softwareVersion": "38.5-43170-DevPreview",
"deviceIds": [
"RINCON_C4T1256L09Q293216" // SunRoomPlayerId
],
"apiVersion": "1.0.0-DevPreview+1234",
"minApiVersion": "1.0.0"
},
{
"id": "RINCON_D7Y5432M12H127890", // FamilyRoomPlayerId
"name": "Family Room",
"icon": "familyroom",
"websocketUrl": "wss://192.168.55.166:1443/websocket/api",
"restUrl": "https://192.168.55.166:1443/api",
"softwareVersion": "38.5-43170-DevPreview",
"deviceIds": [
"RINCON_D7Y5432M12H127890", // FamilyRoomPlayerId
"RINCON_E6O0329J63L098571" // FamilyRoomSubPlayerId
],
"apiVersion": "1.0.0-DevPreview+1234",
"minApiVersion": "1.0.0"
}
]
}
]

这种不规则的json格式该怎么解析???急急急!!!
求解:在一个中括号中有两个大括号,这两个大括号里面的内容是否可以在一起解析,还是说用别的方法解析?
注:规定只能用gson-2.3.1.jar来解决。

4个回答

1、在遇到不合法json的解析时,考虑使用json-lib。http://shensy.iteye.com/blog/1870072

2、用String接收,自己写解析逻辑
https://blog.csdn.net/angle0o/article/details/51836500

以上供参考

qq_33653304
一个人的自在 规定只能使用gson-2.3.1.jar,这样的话该怎么做?
大约 2 年之前 回复

还有楼主给出的json字符串是规则的json格式

qq_33653304
一个人的自在 上面的的数据不在同一个大括号里面,但在同一个中括号里面可以在一起写,一起解析吗?
大约 2 年之前 回复

gson不太适合解析这种json串,建议使用json-20180130先拆一下,在解析方便一些

qq_33653304
一个人的自在 规定只能使用gson-2.3.1.jar,这样的话该怎么做?
大约 2 年之前 回复

可以转换,先转成List> 在根据需要 将Map转成对应的Bean

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐