M
M
mechanicnikodimich2015-07-23 16:58:13
Java
mechanicnikodimich, 2015-07-23 16:58:13

How to transfer JSON from java servlet to mobile client on SWIFT?

Good day!
There is a Restful service, a web server and JAVA servlets. There is a mobile client on SWIFT.
Data is exchanged using json.
I got the data necessary for the user from the database, formed JSONObject (object id).
Could you tell me how then to send JSONObject to the client? Should it be encoded into bytes?
Or is JSONOblect not required here?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zlob, 2015-07-24
@mechanicnikodimich

As a first approximation, it will look something like this

HttpServletResponse response;
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json; charset=UTF-8");
PrintWriter writer = response.getWriter();
writer.print(...);

JSONObject needs to be serialized to string

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question