JSONException: syntax error, expect [, actual {, pos 0

it2022-05-05  82

使用layui动态表格时出现的问题,当需要把一个bean对象转换成jsonarry(似乎layui默认的json格式就是jsonArray)时会出现此异常 解决方法重写 toString方法 ` @Override

public String toString(){ return "[{\"id\":\"" + id + "\", \"orderId\":\"" + orderId + "\", " + "\"productId\":\"" + productId + "\",\"quantity\":\""+quantity+"\"," + "\"totalprice\":\""+totalprice+"\",\"productName\":\""+productName+"\"," + "\"picture\":\""+picture+"\",\"price\":\""+price+"\"," + "\"settlementPrice\":\""+settlementPrice+"\",\"integral\":\""+integral+"\"}]"; }`

在json的最外面加上 []


最新回复(0)