Java (JSONArray、JSONObject、String字符串中)引号""替换成"-"

    xiaoxiao2021-04-13  27

    String value=(a.toString()).replace("\"\"", "\"-\"");

    解释:

    原来,jsonObject传过去有很多空值。

    JSONArray a = new JSONArray();

    jsonObject.accumulate("data", value);

    改一改

    // JSONArray a = new JSONArray();

    // JSONObject a = new JSONObject();

    1.无论什么对象,一律转换成String;

    2.String value=(a.toString()).replace("\"\"", "\"-\"");

    3.jsonObject.accumulate("data", value);

    转载请注明原文地址: https://ju.6miu.com/read-669190.html

    最新回复(0)