Reputation: 2101
How can I decode this JSON String which has been received as a parameter via the ajax call. This String is basically a Javascript Array which has been passed using JSON.stringify
.
The format received at my Java End is something like this.
%5B%22Name%22%2C%22Vivek%22%2C%
how can i decode this String so that I can create a JSONArray from it using
JSONArray.fromObject
because passing the above mentioned format throws an error
Upvotes: 1
Views: 3139
Reputation: 5013
It looks like it is URL encoded. Try decoding it before parsing.
String decodedString = java.net.URLDecoder.decode("%5B%22Name%22%2C%22Vivek%22%2C%", "UTF-8");
JSONArray json = new JSONArray(decodedString);
Upvotes: 6