[英]how to render json in frontend whose size if more than 2gb
GET call /giveMyTree is giving a Json, more than 2 gb in size.In frontend side we are parsing that json and processing on entire json and displaying the data json contains. GET调用/ giveMyTree给出一个大小超过2 gb的Json。在前端,我们正在解析json并在整个json上进行处理并显示json包含的数据。
Json structure is in nested structure. Json结构为嵌套结构。
{ {
tree[1] 树[1]
|_ O{0} | _ O {0}
|_ branch[50]
|__
| Point[1000]
| |___ branch {225}
| :
| :
|___ Line[10000]
: |____start{1}
: | |
: | __ branch{122}
. | :
. | :
|____end{1}
| .....
. :
. :
} }
we display 1000 node, 10000 link and other data after parsing whole json. 解析整个json后,我们将显示1000个节点,10000个链接和其他数据。
I am unable to display this data on browser, browser is either crashing or hangs while processing this data.Is there any way where I can load this data to browser and display the graph to end user. 我无法在浏览器上显示此数据,浏览器在处理此数据时崩溃或挂起。有什么方法可以将这些数据加载到浏览器并向最终用户显示图形。
With the API you designed, there isn't. 使用您设计的API,没有。 The browser will have to load the JSON to parse it, and 2 GB of JSON will create more than 2 GB of JS objects in memory, give or take. 浏览器将必须加载JSON才能对其进行解析,而2 GB的JSON将在内存中创建2 GB以上的JS对象(赠送或接受)。
Even a 4K display can at most show up to 32 MB of data at once (4K*2K*4 = 32M), and if you have mostly text, far less than that, so you don't need 1 GB of data in a single transmission. 即使是4K显示屏,一次最多也可以显示多达32 MB的数据(4K * 2K * 4 = 32M),而且如果您的文本较多,则远远少于此,因此您不需要在其中存储1 GB的数据。单次传输。
Current browsers have problems parsing some hundred megabytes of JSON, so you will have to change your API in such a way that there are smaller chunks transmitted at a time - you should get every JSON answer down to less than 20 MB in size, either by removing details from the general tree (and fetching them when the user opens a single entry), or by breaking the full tree into smaller chunks (only load the root node and all subnodes, and when a subnode is expanded, fetch the sub-subnodes). 当前的浏览器在解析数百兆JSON时遇到问题,因此您必须以这样一种方式更改API,即一次传输的块更小-您应将每个JSON答案的大小减小到20 MB以下从通用树中删除详细信息(并在用户打开单个条目时获取它们),或通过将整个树分成较小的块(仅加载根节点和所有子节点,并且在扩展子节点时,获取子子节点) )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.