- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I was wondering if anyone has experienced ClassCastException when trying to prase a JSON response.
I'm using Postman to run some end to end testing and thought I was getting nothing in the response, but on closer inspection a JSON message is being returned, bit it is throwing a ClassCastException.
I've taken the response and used it to define some test cases to iron out any exceptions, but whenever I try end-to-end testing it throws it again.
Kind regards
Solved! Go to Solution.
โ04-28-2021 11:30 PM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By applying a regex and adding a replace all, we managed to fix the issue and were able to parse the response.
JSONDeserializer<Map<String, Object>> js = new JSONDeserializer<>();
pspResponseMap = js.deserialize(response.replaceAll("[\\p{C}]", ""), Map.class);
โ05-06-2021 10:31 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found the solution.
The JSON responses starts with "ZWNBSP" character (zero width no-break space) in the response.
โ04-30-2021 04:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By applying a regex and adding a replace all, we managed to fix the issue and were able to parse the response.
JSONDeserializer<Map<String, Object>> js = new JSONDeserializer<>();
pspResponseMap = js.deserialize(response.replaceAll("[\\p{C}]", ""), Map.class);
โ05-06-2021 10:31 PM