2
我希望得到这是我的JSONJSON结果 - JAVAME
{"image1.bmp":
{"description": "OK", "filename": "image1.bmp"},
{"image2.bmp":
{"description": "OK", "filename": "image2.bmp"},
{"image3.bmp":
{"description": "OK", "filename": "image3.bmp"}
}
但现在我得到这个代替
{"image1.bmp":
{"description": "OK", "filename": "image1.bmp"}
}
{"image2.bmp":
{"description": "OK", "filename": "image2.bmp"}
}
{"image3.bmp":
{"description": "OK", "filename": "image3.bmp"}
}
这是我对JSON到目前为止
代码public void toJSON(JSONObject outer,String description, String imageName)
{
JSONObject inner = new JSONObject();
try
{
outer.put(imageName, inner);
inner.put("description", description);
inner.put("filename", imageName);
}
catch (JSONException ex) { ex.printStackTrace(); }
}
而且
toJSON(outer,"description:" + e.toString(), "filename:" + imageName);
out.write(outer.toString().getBytes())
看看[http://www.json.org],你所描述的理想结果是无效的JSON,因为第一个`},`后面的表达式不是一个字符串,而是一个对象。 – 2011-02-08 01:59:19