Removing a character from JSONObject?
- by RandomlyKnighted
My JSONObject has some random characters contained within the string so I'm trying to remove them. I've tried this but with no luck.
String result = s.substring(1, s.length() - 2);
JSONObject json_data = new JSONObject(result);
if (json_data.has("["))
{
json_data.remove("[");
}
if (json_data.has("]"))
{
json_data.remove("]");
}
if (json_data.has(","))
{
json_data.remove(",");
}
It's still not removing the characters from the JSONObject. Am I checking the JSONObject for the characters incorrectly?