如何使用Arraylist和Hashmap创建JSON结构

时间:2014-04-14 10:42:44

标签: android json arraylist hashmap

我是android开发的初学者...我想知道如何创建一个json结构,使用arraylists和hashmaps ...你可以找到如下结构... 注意:我不想使用JSONArray或JSONObject

[
[
{
  "blog_owner" : "user",
  "icalIssueEventID" : "",
  "updated_date" : "2014-02-17 07:05:53 +0000",
  "icalEventID" : "",
  "blog_stage" : "Cancelled",
  "blog_ID" : "GMpk20140206160708281",
  "created_date" : "2014-02-06 10:37:38 +0000",
  "emailFlag" : false
}
],
[
{
  "blog_iNotes_ID" : "",
  "blog_name" : "",
  "blog_status" : "",
  "blog_duration" : ""
},
{
  "pid" : "0",
  "isOpen" : true,
  "id" : "R1",
  "level" : 0,
  "value" : [
    {
      "level" : 0,
      "id" : "MA20140206181038936",
      "type" : "meetingAgenda",
      "isOpen" : true,
      "value" : [
        {
          "pid" : "MA20140206181038936",
          "level" : 1,
          "id" : "CN20140207211127374",
          "isOpen" : false,
          "value" : [

          ],
          "line_number" : 13,
          "keyItem" : "Fgh",
          "isCategorySelected" : false
        },
        {
          "line_number" : 14,
          "level" : 1,
          "id" : "CN20140217123343769",
          "isOpen" : true,
          "value" : [

          ],
          "keyItem" : "Fghh",
          "isCategorySelected" : false,
          "pid" : "MA20140206181038936"
        },
        {
          "pid" : "MA20140206181038936",
          "level" : 1,
          "id" : "ISS20140217123542229",
          "isOpen" : true,
          "type" : "Issues",
          "value" : [

          ],
          "type_KeyItem" : {
            "tfImpact" : "",
            "tvIssueDescription" : "",
            "tfActionRequired" : "Ffg",
            "tfResponsible" : "",
            "targetDate" : "Month DD YYYY"
          },
          "keyItem" : "Issues",
          "isCategorySelected" : true,
          "line_number" : 15
        }
      ],
      "type_KeyItem" : {
        "tfAgendaTitle" : "New agenda for magic minutes",
        "lblDuration" : "00:00",
        "tfAgendaName" : ""
      },
      "line_number" : 11,
      "isCategorySelected" : false,
      "pid" : "R1"
    }
  ],
  "isCategorySelected" : false,
  "keyItem" : "root",
  "line_number" : 10
}
],
[
]
]

1 个答案:

答案 0 :(得分:1)

您可以使用google-gson库将JSON转换为Java对象,反之亦然。

其他一些有用的链接是:

1)http://www.javacreed.com/simple-gson-example/

2)http://www.mkyong.com/java/how-do-convert-java-object-to-from-json-format-gson-api/

希望这会对你有所帮助。