dtueufe82643 2016-06-24 07:15
浏览 110

如何将具有多个键值的JSON字符串转换为Android中的JSON对象

This is my JSON data:

{  
   "alldata":[  
      {  
         "college1":{  
            "data":[  
               {  
                  "id":"1",
                  "name":"nithin",
                  "location":"alkd",
                  "time":"2016-06-24 12:02:28"
               },
               {  
                  "id":"2",
                  "name":"xxx",
                  "location":"sdsdvxc",
                  "time":"2016-06-21 12:49:38"
               },
               {  
                  "id":"3",
                  "name":"xcxc",
                  "location":"xzxzx",
                  "time":"2016-06-21 12:59:49"
               },
               {  
                  "id":"4",
                  "name":"ZA",
                  "location":"BU",
                  "time":"2016-06-23 13:04:25"
               },
               {  
                  "id":"5",
                  "name":"df",
                  "location":"ok",
                  "time":"2016-06-20{"                  id":"12",
                  "name":"vbnb",
                  "location":"sf",
                  "time":"2016-06-23 11:08:47"
               },
               {  
                  "id":"13",
                  "name":"az",
                  "location":"vgfjghgbhjj",
                  "time":"2016-06-24 12:13:44"
               }
            ],
            "last_date":"2016-06-24 12:13:44"
         }
      },
      {  
         "product1":{  
            "data":[  
               {  
                  "id":"1",
                  "productname":"soapq",
                  "quantity":"2",
                  "time":"2016-06-23 13:12:27"
               },
               {  
                  "id":"2",
                  "productname":"VCVC",
                  "quantity":"3",
                  "time":"2016-06-23 13:12:13"
               },
               {  
                  "id":"3",
                  "productname":"fym",
                  "quantity":"3",
                  "time":"2016-06-23 13:12:53"
               }
            ],
            "last_date":"2016-06-23 13:12:53"
         }
      }
   ]
}

I want to get these data in to arraylist in Android.

  • 写回答

3条回答 默认 最新

  • doudian7996 2016-06-24 07:30
    关注

    Your JSON data is not valid, i done with corrections as needed for valid JSON data. Check Valid JSON data as follows :

    {
        "alldata": [{
            "college1": {
                "data": [{
                    "id": "1",
                    "name": "nithin",
                    "location": "alkd",
                    "time": "2016-06-24 12:02:28"
                }, {
                    "id": "2",
                    "name": "xxx",
                    "location": "sdsdvxc",
                    "time": "2016-06-21 12:49:38"
                }, {
                    "id": "3",
                    "name": "xcxc",
                    "location": "xzxzx",
                    "time": "2016-06-21 12:59:49"
                }, {
                    "id": "4",
                    "name": "ZA",
                    "location": "BU",
                    "time": "2016-06-23 13:04:25"
                }, {
                    "id": "5",
                    "name": "df",
                    "location": "ok",
                    "time": "2016-06-20"
                }, {
                    "id": "12",
                    "name": "vbnb",
                    "location": "sf",
                    "time": "2016-06-23 11:08:47"
                }, {
                    "id": "13",
                    "name": "az",
                    "location": "vgfjghgbhjj",
                    "time": "2016-06-24 12:13:44"
                }],
                "last_date": "2016-06-24 12:13:44"
            }
        }, {
            "product1": {
                "data": [{
                    "id": "1",
                    "productname": "soapq",
                    "quantity": "2",
                    "time": "2016-06-23 13:12:27"
                }, {
                    "id": "2",
                    "productname": "VCVC",
                    "quantity": "3",
                    "time": "2016-06-23 13:12:13"
                }, {
                    "id": "3",
                    "productname": "fym",
                    "quantity": "3",
                    "time": "2016-06-23 13:12:53"
                }],
                "last_date": "2016-06-23 13:12:53"
            }
        }]
    }
    

    then try this tutorial - http://www.tutorialspoint.com/android/android_json_parser.htm

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器