嗨我需要在从JSON调用数据时识别多个具有不同名称的String LngLng,以自动乘以响应,这样就可以创建多样化的名称,如name1,name2,name3 ......这将根据来自它的数据量获得JSON
LatLng name1 = new LatLng (6.3490548, -75.5580200);
LatLng name2 = new LatLng (6.33, -75.56);... // to create this automatically, only changing name
我的JSON代码
StringRequest strReq = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.e("Response: ", response);
try {
JSONObject jObj = new JSONObject(response);
String getObject = jObj.getString("saagMRK");
JSONArray jsonArray = new JSONArray(getObject);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
LatLng name1 = new LatLng(parseDouble(jsonObject.getString(LAT)), parseDouble(jsonObject.getString(LNG)));// Multiply this line only changed the name1 to name2 to name3 automatically
...