I have a JSON string:
{
"_id": -1,
"create_date": 0,
"update_date": 0,
"description": "test",
"active": true
}
In Java, I try to parse it using org.json.simple.parser.JSONParser :
JSONParser jsonParser = new JSONParser();
org.json.simple.JSONObject jsonObject = (org.json.simple.JSONObject) jsonParser.parse(phoneJSON);
I try to retrieve the _id field value:
String s_id = ((String) jsonObject.get("_id"));
but encounter the following exception:
java.lang.Long cannot be cast to java.lang.String
Furthermore, if I display the field value in the console:
System.out.println("print value - _id: "+jsonObject.get("_id"));
I get:
print value - _id: -1
output in the console.
I have seen this post:
java.lang.Long cannot be cast to java.lang.String
But is does not help me.
What am I not understanding?