I have a JSON file and I want to send it to the RequestHandler. The error response is the following:
java.util.LinkedHashMap cannot be cast to java.lang.String
1 Answer
You're attempting to send a LinkedHashMap, as the error and @Mark B says, to the RequestHandler. Instead, "stringify" it into a JSON string first. I recommend one of two libraries for this.
Google's GSON library
String jsonString = new Gson().toJson(jsonData, LinkedHashMap.class);
Java's JSON library
String jsonString = new JSONObject(jsonData).toString()
Then, send this string to the RequestHandler. Hope this helps.
LinkedHashMapin your application's memory according to the error message. So you need to lookup how to convert aHashMapto a JSON String.