我在解析 Android 中的 JSON 包时遇到了一些困难。
我目前已经完成了所有设置,因此 JSON 是一个对象数组,然后每个对象都有一个属性数组。例如,假设我的包中有一个名为 Colors 的对象。然后每个 Color 条目将位于 Colors 对象中。每个颜色条目也将包含 R、G、B 值的条目。
这种类型,我可以应付得很好。但是,我现在遇到了一个实例,其中其中一个条目(R、G、B 值所在的位置)中有一个数组。我不知道如何去访问和处理它。
我将使用 JSON 包的示例进行更新,因为我担心我不是很清楚。
编辑:这是 JSON。假设我想访问 ColorOverlays 中的 R 值。
{"Package":[ {"Things":[{"ProgramId":73,"TypeId":68,"CategoryId":null,"CategoryName":null,"ThingId":121,"ThingName":"Mahalo" ,"ThingDescription":"开始您的节日并拍摄一些照片!","ThingPrice":0.00,"SellerProductId":null,"Number2":1342655700,"Number1":1342655700,"IsAvailable":true,"ImageOverlays" :[{"ThingId":121,"ThingOverlayId":295,"ImageOverlayBase64":null,"ImageOverlayFileTypeExtension":null,"Width":1024,"Height":1024,"A":1.00000,"BlendModeId":1 ,"OrderNum":2,"IsUseSource":false}],"ColorOverlays":[{"ThingId":121,"ThingOverlayId":294,"R":157.00000,"G":71.00000,"B":187.00000,"A":0.52873,"BlendModeId":6,"OrderNum":1}],"ThingsampleImageBase64":null,"ThingsampleImageFileTypeExtension":"", "ThingsampleImageWidth":546,"ThingsampleImageHeight":546,"Captures":[{"ThingCaptureId":87,"ThingId":121,"CaptureFrameOverlayId":null,"IsRemoved":false,"AddDate":1342637814,"LastUpdated ":1342637814,"饱和度":0.0,"对比度":0.0,"亮度":0.0,"低":null,"中":null,"高":null,"IsBlackWhite":null,"IsInvert": null,"IsSepia":null}],"IsRemoved":false},{"ProgramId":73,"TypeId":68,"CategoryId":null,"CategoryName":null,"ThingId":122,"ThingName":"Lots of Love","ThingDescription":"使用这个!","ThingPrice":0.00,"SellerProductId":null,"Number2":1342667100 ,"Number1":1342667100,"IsAvailable":true,"ImageOverlays":[{"ThingId":122,"ThingOverlayId":298,"ImageOverlayBase64":null,"ImageOverlayFileTypeExtension":null,"Width":1024,"高度":1024,"A":1.00000,"BlendModeId":4,"OrderNum":3,"IsUseSource":false}],"ColorOverlays":[{"ThingId":122,"ThingOverlayId":296," R":213.00000,"G":86.00000,"B":143.00000,"A":0.77777,"BlendModeId":4,"OrderNum":1},{"ThingId":122,"ThingOverlayId":297,"R":127.00000,"G":127.00000,"B":127.00000,"A":0.50000,"BlendModeId":1,"OrderNum":2}]," ThingsampleImageBase64":null,"ThingsampleImageFileTypeExtension":"","ThingsampleImageWidth":546,"ThingsampleImageHeight":546,"Captures":[{"ThingCaptureId":88,"ThingId":122,"CaptureFrameOverlayId":null,"IsRemoved ":false,"AddDate":1342649164,"LastUpdated":1342649164,"Saturation":0.0,"Contrast":0.0,"Brightness":0.0,"Low":null,"Mid":null,"High": null,"IsBlackWhite":null,"IsInvert":null,"IsSepia":null}],"IsRemoved":false}]} ]}ThingOverlayId":297,"R":127.00000,"G":127.00000,"B":127.00000,"A":0.50000,"BlendModeId":1,"OrderNum":2}],"ThingsampleImageBase64":null," ThingsampleImageFileTypeExtension":"","ThingsampleImageWidth":546,"ThingsampleImageHeight":546,"Captures":[{"ThingCaptureId":88,"ThingId":122,"CaptureFrameOverlayId":null,"IsRemoved":false,"AddDate ":1342649164,"LastUpdated":1342649164,"Saturation":0.0,"Contrast":0.0,"Brightness":0.0,"Low":null,"Mid":null,"High":null,"IsBlackWhite": null,"IsInvert":null,"IsSepia":null}],"IsRemoved":false}]} ]}ThingOverlayId":297,"R":127.00000,"G":127.00000,"B":127.00000,"A":0.50000,"BlendModeId":1,"OrderNum":2}],"ThingsampleImageBase64":null," ThingsampleImageFileTypeExtension":"","ThingsampleImageWidth":546,"ThingsampleImageHeight":546,"Captures":[{"ThingCaptureId":88,"ThingId":122,"CaptureFrameOverlayId":null,"IsRemoved":false,"AddDate ":1342649164,"LastUpdated":1342649164,"Saturation":0.0,"Contrast":0.0,"Brightness":0.0,"Low":null,"Mid":null,"High":null,"IsBlackWhite": null,"IsInvert":null,"IsSepia":null}],"IsRemoved":false}]} ]}00000,"G":127.00000,"B":127.00000,"A":0.50000,"BlendModeId":1,"OrderNum":2}],"ThingsampleImageBase64":null,"ThingsampleImageFileTypeExtension":"","ThingsampleImageWidth" :546,"ThingsampleImageHeight":546,"Captures":[{"ThingCaptureId":88,"ThingId":122,"CaptureFrameOverlayId":null,"IsRemoved":false,"AddDate":1342649164,"LastUpdated":1342649164 ,"饱和度":0.0,"对比度":0.0,"亮度":0.0,"低":null,"中":null,"高":null,"IsBlackWhite":null,"IsInvert":null," IsSepia":null}],"IsRemoved":false}]} ]}00000,"G":127.00000,"B":127.00000,"A":0.50000,"BlendModeId":1,"OrderNum":2}],"ThingsampleImageBase64":null,"ThingsampleImageFileTypeExtension":"","ThingsampleImageWidth" :546,"ThingsampleImageHeight":546,"Captures":[{"ThingCaptureId":88,"ThingId":122,"CaptureFrameOverlayId":null,"IsRemoved":false,"AddDate":1342649164,"LastUpdated":1342649164 ,"饱和度":0.0,"对比度":0.0,"亮度":0.0,"低":null,"中":null,"高":null,"IsBlackWhite":null,"IsInvert":null," IsSepia":null}],"IsRemoved":false}]} ]}BlendModeId":1,"OrderNum":2}],"ThingsampleImageBase64":null,"ThingsampleImageFileTypeExtension":"","ThingsampleImageWidth":546,"ThingsampleImageHeight":546,"Captures":[{"ThingCaptureId":88, "ThingId":122,"CaptureFrameOverlayId":null,"IsRemoved":false,"AddDate":1342649164,"LastUpdated":1342649164,"Saturation":0.0,"Contrast":0.0,"Brightness":0.0,"Low ":null,"Mid":null,"High":null,"IsBlackWhite":null,"IsInvert":null,"IsSepia":null}],"IsRemoved":false}]} ]}BlendModeId":1,"OrderNum":2}],"ThingsampleImageBase64":null,"ThingsampleImageFileTypeExtension":"","ThingsampleImageWidth":546,"ThingsampleImageHeight":546,"Captures":[{"ThingCaptureId":88, "ThingId":122,"CaptureFrameOverlayId":null,"IsRemoved":false,"AddDate":1342649164,"LastUpdated":1342649164,"Saturation":0.0,"Contrast":0.0,"Brightness":0.0,"Low ":null,"Mid":null,"High":null,"IsBlackWhite":null,"IsInvert":null,"IsSepia":null}],"IsRemoved":false}]} ]}546,"ThingsampleImageHeight":546,"Captures":[{"ThingCaptureId":88,"ThingId":122,"CaptureFrameOverlayId":null,"IsRemoved":false,"AddDate":1342649164,"LastUpdated":1342649164, "饱和度":0.0,"对比度":0.0,"亮度":0.0,"低":null,"中":null,"高":null,"IsBlackWhite":null,"IsInvert":null,"IsSepia ":null}],"IsRemoved":false}]} ]}546,"ThingsampleImageHeight":546,"Captures":[{"ThingCaptureId":88,"ThingId":122,"CaptureFrameOverlayId":null,"IsRemoved":false,"AddDate":1342649164,"LastUpdated":1342649164, "饱和度":0.0,"对比度":0.0,"亮度":0.0,"低":null,"中":null,"高":null,"IsBlackWhite":null,"IsInvert":null,"IsSepia ":null}],"IsRemoved":false}]} ]}null,"Mid":null,"High":null,"IsBlackWhite":null,"IsInvert":null,"IsSepia":null}],"IsRemoved":false}]} ]}null,"Mid":null,"High":null,"IsBlackWhite":null,"IsInvert":null,"IsSepia":null}],"IsRemoved":false}]} ]}