Community
Participate
Working Groups
Sometimes JSON data values contains a value with some special characters, which are a part of JSON structure. Then client JSON parser not able to read JSON correctly. Now all value field's are encode using the JAVA encoding: java.net.URLEncoder.encode(val, "UTF-8") All web Client should decode the values while reading JSON data using the custom JavaScript decode method: decode = function(str) { str = '' + str; str = str.replace(/\+/g, " "); str = str.replace(/%7E/g, "~"); str = str.replace(/%21/g, "!"); str = str.replace(/%27/g, "'"); str = str.replace(/%28/g, "("); str = str.replace(/%29/g, ")"); return decodeURIComponent(str); } And Java client should use: java.net.URLDecoder.decode(val, "UTF-8")
Created attachment 195255 [details] JSON Fixes Adding Snehasish's patch.
The patch looks good - values are encoded. However, the decode function described only decodes a handful of characters. Many other special characters are encoded in the return data, so you need to decode all of them for an accurate read.
(In reply to comment #2) > The patch looks good - values are encoded. However, the decode function > described only decodes a handful of characters. Many other special characters > are encoded in the return data, so you need to decode all of them for an > accurate read. Sorry - missed the last line: return decodeURIComponent(str); If decodeURIComponent(str) takes care of the rest of the special characters, I think we may be all set.
Patch looks good to me also, committed to HEAD.