Struts:JSON:返回多个对象
Struts1是否可以在请求头中返回多个JSON对象?我目前返回单个 JSON 对象,但现在需要返回第二个数据结构。所有客户端处理都非常适合单个 JSON 对象中的单个数据结构,我真的不想通过将两个异构数据结构放入单个返回 JSON 对象中来使其复杂化。蒂亚。
Is it possible to return multiple JSON objects in the request header with Struts1? I am presently returning a single JSON objects, however the need now is to return a second data structure. All the client-side processing works perfectly for the single data structure in the single JSON objects, I really do not want to complicate it by putting two hetrogenous data structures in a single return JSON object. tia.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道 struts 也不知道为什么你不能返回多个 JSON 对象,但如果你真的不能,为什么不返回对象列表呢?您可以在接收端将它们拆箱。
换句话说,如果您之前返回 obj = {...},现在需要返回 obj = {...},则可以返回 [obj, obj2]。
也许这不能解决你的问题,但它会让你很容易地解决它。
I don't know struts or why you can't return multiple JSON objects, but if you genuinely can't, why don't you return a list of your objects? you can unbox them at the receiving end.
in other words, if you were previously returning obj = {...}, and now need to return that as well as obj2 = {...}, you can return [obj, obj2].
maybe this doesn't solve your problem, but it'll get you around it pretty easily.