我想要键和条码一样的值:从json值

时间:2017-06-07 05:49:31

标签: android-studio

{     "条形码":null,     "品牌":null,     "颜色":" RED",     "部门":null,     "深度":0,     " DueDate":null,     "身高":0,     " Innerqty":1000,     " IsActive":是的,     " IsBuyOutOfStock":false,     " IsNew":假,     " IsOutOfStock":false,     " IsSpecialOffer":false,     " IsVatApply":false,     " Isbestdeal":假,     " ItemType":1,     " MSRP":null,     " MainBigThumb":null,     " MainImage":null,     " MainSmallImages":null,     "优惠价格":0,     " Outerqty":100,     "价格":1000,     " PriceBand":null,     " ProductDescription":"

产品说明< / p> \ r \ n",     " ProductDescription3":"

产品说明3< / p> \ r \ n",     " ProductDescription4":"

产品说明4< / p> \ r \ n",     " ProductGroupCode":null,     " ProductImage1_Large":null,     " ProductImage2":null,     " ProductImage2_Large":null,     " ProductImage2_Thumb":null,     " ProductImage3":null,     " ProductImage3_Large":null,     " ProductImage3_Thumb":null,     " ProductSummary":"产品摘要",     " ProductVisiblity":" All",     "产品代码":" Multi-00007",     " RRP":1000,     "尺寸":" XL",     " Sku_Description":" Multi-000072",     " StockDate":null,     " StockKeepingunit":" Multi-000072_2",     " StockQty":100,     "供应商":null,     " SupplierPartNumber":null,     " Tax_Code":null,     "缩略图":null,     " UPC":null,     " UnitOfSale":null,     " VatProductPostingGroup":null,     " Vat_Percentage":10,     "体重":0,     "宽度":0,     " isProductConfigurable":false,     " IndexNumber":null,     " Web1_Category":null,     " Web1_Category_1":null,     " Web1_Category_2":null,     " Web2_Category":null,     " Web2_Category_1":null,     " Web2_Category_2":null,     " Web_Category":"",     " Web_Category_1":"",     " Web_Category_2":"" } {     "条形码":null,     "品牌":null,     "颜色":" RED",     "部门":null,     "深度":0,     " DueDate":null,     "身高":0,     " Innerqty":1000,     " IsActive":是的,     " IsBuyOutOfStock":false,     " IsNew":假,     " IsOutOfStock":false,     " IsSpecialOffer":false,     " IsVatApply":false,     " Isbestdeal":假,     " ItemType":1,     " MSRP":null,     " MainBigThumb":" rsz_390b37be04c34a7099951612b09b0efa.jpg",     " MainImage":" rsz_e4217163f7eb401b9204c4543110925a.jpg",     " MainSmallImages":" rsz_275e5e51603c49b2ac21ed023965544c.jpg",     "优惠价格":0,     " Outerqty":100,     "价格":1000,     " PriceBand":null,     " ProductDescription":"

产品说明< / p> \ r \ n",     " ProductDescription3":"

产品说明3< / p> \ r \ n",     " ProductDescription4":"

产品说明4< / p> \ r \ n",     " ProductGroupCode":null,     " ProductImage1_Large":" rsz_60f8111b3605457d9f971cf0f60b15f1.jpg",     " ProductImage2":" rsz_d88eb3ba241a4e60b9b77a46b9165551.jpg",     " ProductImage2_Large":" rsz_1617bb90f96e41a4925bac2a483d32d1.jpg",     " ProductImage2_Thumb":" rsz_e57028cc675d4ccdb63640b685447390.jpg",     " ProductImage3":" rsz_c5d14b3239e348d7a970fa3be583647c.jpg",     " ProductImage3_Large":" rsz_b9021dde26c6455a95e7849ee795ca1a.jpg",     " ProductImage3_Thumb":" rsz_b8cd1eb8c9e84593b9e69feb6ce6c8dd.jpg",     " ProductSummary":"产品摘要",     " ProductVisiblity":" All",     "产品代码":" Multi-00007",     " RRP":1000,     "尺寸":" XL",     " Sku_Description":" Multi-000072",     " StockDate":null,     " StockKeepingunit":" Multi-000072",     " StockQty":100,     "供应商":null,     " SupplierPartNumber":null,     " Tax_Code":null,     "缩略图":" rsz_6a67f865f3e44fdea309cd672145193e.jpg",     " UPC":null,     " UnitOfSale":null,     " VatProductPostingGroup":null,     " Vat_Percentage":10,     "体重":0,     "宽度":0,     " isProductConfigurable":false,     " IndexNumber":null,     " Web1_Category":null,     " Web1_Category_1":null,     " Web1_Category_2":null,     " Web2_Category":null,     " Web2_Category_1":null,     " Web2_Category_2":null,     " Web_Category":"",     " Web_Category_1":"",     " Web_Category_2":"" } {     "条形码":null,     "品牌":null,     "颜色":" RED",     "部门":null,     "深度":0,     " DueDate":null,     "身高":0,     " Innerqty":1000,     " IsActive":是的,     " IsBuyOutOfStock":false,     " IsNew":假,     " IsOutOfStock":false,     " IsSpecialOffer":false,     " IsVatApply":false,     " Isbestdeal":假,     " ItemType":1,     " MSRP":null,     " MainBigThumb":null,     " MainImage":null,     " MainSmallImages":null,     "优惠价格":0,     " Outerqty":100,     "价格":1000,     " PriceBand":null,     " ProductDescription":"

产品说明< / p> \ r \ n",     " ProductDescription3":"

产品说明3< / p> \ r \ n",     " ProductDescription4":"

产品说明4< / p> \ r \ n",     " ProductGroupCode":null,     " ProductImage1_Large":null,     " ProductImage2":null,     " ProductImage2_Large":null,     " ProductImage2_Thumb":null,     " ProductImage3":null,     " ProductImage3_Large":null,     " ProductImage3_Thumb":null,     " ProductSummary":"产品摘要",     " ProductVisiblity":" All",     "产品代码":" Multi-00007",     " RRP":1000,     "尺寸":" XL",     " Sku_Description":" Multi-000072",     " StockDate":null,     " StockKeepingunit":" Multi-000072_2",     " StockQty":100,     "供应商":null,     " SupplierPartNumber":null,     " Tax_Code":null,     "缩略图":null,     " UPC":null,     " UnitOfSale":null,     " VatProductPostingGroup":null,     " Vat_Percentage":10,     "体重":0,     "宽度":0,     " isProductConfigurable":false,     " IndexNumber":null,     " Web1_Category":null,     " Web1_Category_1":null,     " Web1_Category_2":null,     " Web2_Category":null,     " Web2_Category_1":null,     " Web2_Category_2":null,     " Web_Category":"",     " Web_Category_1":"",     " Web_Category_2":"" }

1 个答案:

答案 0 :(得分:0)

试试这个。

String json = "[{ Barcode: 5022481129341, Brand: new, Color: null, }] ";
    try {
        JSONArray jsonArray = new JSONArray(json);
        JSONObject jsonObject = jsonArray.getJSONObject(0);
        ArrayList<String> keyArray = new ArrayList<>();
        for(int i = 0; i<jsonObject.names().length(); i++){
            Log.v("", "key = " + jsonObject.names().getString(i) + " value = " + jsonObject.get(jsonObject.names().getString(i)));
            keyArray.add(jsonObject.names().getString(i) + " : " + jsonObject.get(jsonObject.names().getString(i)));
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }