Android Json Object放置了一个没有密钥的数组JSON

问题描述

我需要创建一个具有estructure的json

    {
      "label": "any description","location":[25.7752965,-100.2636682]
    }

Json对象,其数组不包含键,值(位置),

我尝试

String[] _location = new String[2];
_location[0] = String.valueOf(latLng.latitude);
_location[1] = String.valueOf(latLng.longitude);

JSONObject params = new JSONObject();
params.put("location",_location);
params.put("label",_label);

另一个尝试使用:

       JsonObject obj = new JsonObject();
       JsonArray array_location = new JsonArray();
       array_location.add(currentLocation.latitude);
       array_location.add(currentLocation.longitude);
       JSONObject params = new JSONObject();
       params.put("location",_location);
       params.put("label",_label);

但是,结果给了我一个带有字符串值的json ...当我需要一个值为数组double的键“位置”时

 {
     "label": "any description","location":"[25.7752965,-100.2636682]"
  }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)