This is actually a JSON
:
{
"level": "INFO",
"message": "89532154: phone number saved successfully."
}
You should be able to get the INFO
like this from level
:
JSONObject obj = new JSONObject(yourcurrentjson);
String levelOutput = obj.getString("level");
// level output should return the INFO
And this with regex
:
Map<String, Integer> map = new HashMap<>();
for (String keyValue: json.split(",")) {
String[] data = keyValue.split(":");
map.put(
data[0].replace("\"", """),
Integer.valueOf(data[1].trim());
);
}
And then: map.get(key)
for getting integers and this:
String.format("\"%s\"\\s*:\\s*\"((?=[ -~])[^\"]+)\"", id_field)
For getting strings like in your case.
Check this out: https://stackoverflow.com/a/37828403/4409113