【问题标题】:merging multiple JSON objects in an existing JSON array合并现有 JSON 数组中的多个 JSON 对象
【发布时间】:2018-03-26 11:26:16
【问题描述】:

我有一个如下的jsonarray:

 [
   {
      "WarrantyGuarantee":{
         "Row Id":"RA048",
         "QuestionKey":"WarrantyGuarantee",
         "Answer":"Y"
      }
   },
   {
      "RewardLoyalty":{
         "Row Id":"RA051",
         "QuestionKey":"RewardLoyalty",
         "Answer":"Y"
      }
   },
   {
      "WarrantyGuarantee":{
         "Row Id":"RA048",
         "QuestionKey":"WarrantyGuarantee",
         "Answer":"Y"
      }
   },
   {
      "RewardLoyalty":{
         "Row Id":"RA051",
         "QuestionKey":"RewardLoyalty",
         "Answer":"Y"
      }
   },
   {
      "MinCost":{
         "Row Id":"RA044",
         "QuestionKey":"MinCost",
         "Answer":"hgf"
      }
   }
]

我也有多个 json 对象:

  {
   "RA048":"Y",
   "RA051":"Y"
  }

 {
   "RA049":"Y",
   "RA051":"N"
 }

我想从上面的 jsonarray 中合并我所有的 json 对象。

【问题讨论】:

标签: android json android-json


【解决方案1】:
JSONObject jo = new JSONObject();
JSONArray array = new JSONArray();
jo.put("key",(Object)array);

使用这个方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-30
    • 1970-01-01
    • 2013-06-04
    • 1970-01-01
    相关资源
    最近更新 更多