开发者

How to retrieve a JSON object from HttpServletResponse in Spring?

开发者 https://www.devze.com 2023-01-18 03:07 出处:网络
I have a Spring controller in which I have to read a JSON object from a URLConnection. Currently I am doing this by reading from the conn开发者_Python百科ection\'s input stream line by line. Basically

I have a Spring controller in which I have to read a JSON object from a URLConnection. Currently I am doing this by reading from the conn开发者_Python百科ection's input stream line by line. Basically I am reading the text contents of the response line by line.

Is there any JSON api that I could use to populate the JSON object directly from the URLConnection? Anything that integrates with Spring?


Perhaps this is related? Essentially, implementing JsonView.


http://jackson.codehaus.org/1.6.0/javadoc/org/codehaus/jackson/JsonFactory.html#createJsonParser(java.io.InputStream) This could help, as URLConnection can return InputStream. What do you want to integrate with Spring, btw?

0

精彩评论

暂无评论...
验证码 换一张
取 消