返回 JSONArray 作为 HTTP 实体
摘要:我想通过 HTTP 响应返回 JSONArray。我该怎么做?
我正在解决一个问题,我之前返回一个 JSON 对象,该对象被转换为 JSONEntity,然后使用我拥有的实用程序转换为 HTTPEntity。现在我需要返回一个 JSONArray,但我不知道如何让我的 REST 服务返回该数组。如果有人可以帮助我,我将非常感激。
谢谢!
一点背景: 我之前使用 DOJO ItemWriteStore 来构建一棵树。现在我正在切换到 JSONRestStore 以使我的树能够延迟加载。出现这个问题是因为 Dojo 中的大多数存储都采用 JSONObjects,但支持延迟加载的 JSONRestStore 需要 JSONArray。
Aslo,我正在使用 org.apache.http 包作为我的 HTTP 响应
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 json-simple 库将其编码为 JSONArray 对象。
You could use the json-simple library to encode it into a JSONArray object.