简体   繁体   中英

Return a JSONArray as an HTTP Entity

Summary : I want to return a JSONArray via an HTTP response. How do I do that?

I am working on a problem where I was previously returning a JSON object, which was being converted to JSONEntity and then a HTTPEntity using a utility that I have. Now I need to return an JSONArray, but I don't know how to have my REST service return the array. If someone could help me I would really appreciate it.

Thanks!

A little background: I was previously using a DOJO ItemWriteStore to build a tree. Now I am switching to a JSONRestStore to enable my tree to have lazy loading. The problem came up because most stores in Dojo take JSONObjects, but the JSONRestStore, which supports lazy loading, needs a JSONArray.

Aslo, I am using the org.apache.http package for my HTTP repsonse

您可以使用json-simple库将其编码为JSONArray对象。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM