如何在json对象中传递对象列表

嗨,我正在开发小应用程序,我试图在http post方法中传递一些数据.所以我想发送我的数据,如此表单

"storeid": "151",
    "floordata": {
    "entry": [
        10,
        15
    ],
    "exit": [
        10,
        15
    ],

    "section": [
        {
            "id": "0",
            "sectionname": "ABC",
            "category": "office",
           "boundary": [
                [
                    85,
                    258
                ],
                [
                    85,
                    298
                ],
                [
                    125,
                    298
                ],
                [
                    125,
                    258
                ],
                [
                    85,
                    258
                ]
            "description": "Mobile based company"
        }
    ]
    },
    "category": null,
    "description": null

所以我的问题是关于section参数.我正在为section参数做这个.

        String section = "section=";

        // Problem for me is here ... 
        JSONArray sections = new JSONArray();

        List<List<Float>> sectionCords = new ArrayList<List<Float>>();
        List<Float> sectionCordData = new ArrayList<Float>();
        sectionCordData.add(0.0f);
        sectionCordData.add(0.1f);

        List<Float> sectionCordData1 = new ArrayList<Float>();
        sectionCordData1.add(0.0f);
        sectionCordData1.add(0.1f);

        sectionCords.add(sectionCordData);
        sectionCords.add(sectionCordData1);

        JSONObject sectionObj = new JSONObject();
        //List<JSONObject> cordList = new ArrayList<JSONObject>();

        try {
            sectionObj.put("category", "office");
            sectionObj.put("description", "Mobile based company");
            sectionObj.put("sectionname", "mobiotics");
            sectionObj.put("id", 0);
            sectionObj.put("boundary", sectionCords); // Check Here i am sending as list ...

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        sections.put(sectionObj);
        section += sections;

        section +="&";

但实际上我的部分边界参数以字符串而不是列表的形式出现.像这样

 boundary=[
  [
    0.0,
    0.1
  ],
  [
    0.0,
    0.1
  ]
],storeid=156&floor=2&section=[
  {
    "id": 0,
    "sectionname": "mobiotics",
    "category": "office",
    "boundary": "[[0.0, 0.1], [0.0, 0.1]]", // See here is my problem ...
    "description": "Mobile based company"
  }
],entry=[
  10,
  15
],exit=[
  10,
  15
]   

如何将其作为列表而不是字符串发送.需要帮忙.谢谢.

最佳答案 将sectionChords和sectionCordData *定义为JSONArray而不是List:

JSONArray sectionChords = new JSONArray();
    JSONArray sectionCordData = new JSONArray();
    sectionCordData.put(0.0f);
    sectionCordData.put(0.1f);

    JSONArray sectionCordData1 = new JSONArray();
    sectionCordData1.put(0.0f);
    sectionCordData1.put(0.1f);

    sectionCords.put(sectionCordData);
    sectionCords.put(sectionCordData1);
点赞