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:
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());
}
quotes in arrays depends on which JOSN Lib are using:
org.codehaus.jettison.json.JSONArray or org.json.JSONArray
String mailMessage = JSONObject.toJSONString("JsonObject").replace("\"", " ").trim();
What worked for me is
defect.get("FormattedID").toString().substring(1,defect.get("FormattedID").toString().length()-1)
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
just
s.replaceAll("\"", "");
removes all " characters in your string.
or in your case
testValue.toString().replaceAll("\"", "");