Question

The Inputstream that i receive from a post request through ExtJS is in CP1252 encoding. How do i decode the Inputsteam so that i can use the json string and convert it to the appropriate java bean.

I found out the encoding by using the InputStreamReader's getEncoding() method.

ExtJs sends the data in the following format:

recordsToSend=%5B%7B%22StartDate%22%3A%222011-03-23T00%3A00%3A00%22%2C%22EndDate%22%3A%222011-03-23T01%3A00%3A00%22%2C%22IsAllDay%22%3Afalse%2C%22CalendarId%22%3A1%2C%22Title%22%3A%22saved%22%7D%5D

Need to convert it to:

[{"StartDate":"2011-03-23T00:00:00","EndDate":"2011-03-23T01:00:00","IsAllDay":false,"CalendarId":1,"Title":"saved"}]
Was it helpful?

Solution

That's not a character encoding in the normal chars-to-bytes sense. It's some form of escaping. Probably URL escaping. See if java.net.URLDecoder helps.

The InputStreamReader.getEncoding() method only tells you the encoding the reader is using to decode the bytes from the underlying input stream, and this is specified at construction time, or set to the platform default if omitted. It doesn't tell you anything about the actual encoding of the characters in the underlying byte stream.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top