以多部分数据或多部分形式发送大型响应Json [英] Send a large response Json as multipart-data or in multiple parts

查看:68
本文介绍了以多部分数据或多部分形式发送大型响应Json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我要有一个巨大的响应json,其中包含将图像作为base64数据传递到json的图像.json中有许多这些base64字符串数据,每个数据都是巨大的,因为这些图像的大小也为5-10 Mb.因此,json大小变大.我想知道是否有任何方法可以将这个巨大的json转换为多部分数据,或者是否有任何方法可以打破这个巨大的响应json并在一个http请求中将它们分成多个部分发送.任何人都可以在上述方面提供一些帮助.

I have a requirement where I have a huge response json which contains images which are passed into json as base64 data. There are many of these base64 string data in the json, each of which are huge, as these images are also of size 5-10 Mb. Hence the json size becomes large. I want to know if there is any way to convert this huge json to multipart-data or if there is any way to break this huge response json and send them in multiple parts in a single http request. Can anyone please provide some help on the above.

推荐答案

一些选项,但使用Java的JSON解析器Jackson可能最容易.Jackson可以将一个较大的JSON对象拆分为多个较小的对象,这些对象可以发送给客户端.这是教程.

A few options, but might be easiest to use Jackson, a JSON parser for Java. Jackson can split a large JSON object into multiple, smaller objects that can be sent to the client. Here's a tutorial.

请参阅此堆栈溢出响应其他选项.

See this Stack Overflow response for other options.

这篇关于以多部分数据或多部分形式发送大型响应Json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆