Server(Java) sends a Json String to a client(TypeScript). On the client I get the following:
Therefore JSON.parse()
fails due to question marks being appended.
I tried:
- Setting content type to - "text/html"
- Setting encode to - "UTF-8"
And nothing seem to remove these.
My code:
public class objectOutput {
static int i=0;
ObjectOutputStream objectOutputStream;
public objectOutput(HttpServletResponse response) throws IOException {
response.setContentType("application/octet-stream");
objectOutputStream = new ObjectOutputStream(response.getOutputStream());
}
// Using this method to write a Json String
public void writeObject(Object object) throws IOException {
objectOutputStream.writeObject(object);
objectOutputStream.close();
objectOutputStream.flush();
}
}