Remove quote from the JSONArray output

后端 未结 13 1742
野性不改
野性不改 2021-01-02 02:45

On the successful call, I am getting the JSONArray with the key \"objects\" and again the testValue with the key \"name\". The output is Like:



        
相关标签:
13条回答
  • 2021-01-02 03:13

    This thread is pretty old, but I stumbled upon the same problem an hour ago and found the correct solution. You have to check for the type of JsonValue and if its a JsonString, you can parse it to JsonString and call its getString() method.

    if(val.getValueType().equals(JsonValue.ValueType.STRING)) {
      c.setValue(((JsonString) val).getString());
    } else {
      c.setValue(val.toString());
    }
    
    0 讨论(0)
  • 2021-01-02 03:13

    quotes in arrays depends on which JOSN Lib are using:

    org.codehaus.jettison.json.JSONArray or org.json.JSONArray

    0 讨论(0)
  • 2021-01-02 03:16

    String mailMessage = JSONObject.toJSONString("JsonObject").replace("\"", " ").trim();

    0 讨论(0)
  • 2021-01-02 03:17

    What worked for me is

    defect.get("FormattedID").toString().substring(1,defect.get("FormattedID").toString().length()-1)
    
    0 讨论(0)
  • 2021-01-02 03:24

    you can use the below to get string without double quotes

        JsonObject childJSONObject = new JsonObject(); 
       JSONValue testValue = childJSONObject.get("name").getAsString();
    

    this gives the string without double quotes " " in the string

    0 讨论(0)
  • 2021-01-02 03:25

    just

    s.replaceAll("\"", "");
    

    removes all " characters in your string.

    or in your case

    testValue.toString().replaceAll("\"", "");
    
    0 讨论(0)
提交回复
热议问题