简体   繁体   English

如何在大小超过2gb的前端渲染json

[英]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.

相关问题 如何使用 Javascript 或 Angular2 上传大文件制作成块文件(切片大小:2GB)? - How to upload large file make into chunk files (Slice Size:2GB) using Javascript or Angular2? 在大小超过3 GB的Amazon S3上上传文件 - Upload file on amazon S3 of size more than 3 gb 上传大文件〜2GB大小会导致浏览器错误 - Upload a huge file ~2GB size causes browser error 如何在前端HTML页面上呈现JSON - How to render JSON on a frontend html page 如果文件长度超过 1 GB,如何将文件表单客户端上传到服务器? - How to upload the file form client to server if the file length is more than 1 gb? 在读取超过2GB的大文本文件时,如何解决缓冲区溢出? - How to resolve Buffer overflow while reading large text files over 2GB? 在useEffect中有多个setState,如何避免重新渲染? - more than one setState in useEffect, how to aviod re-render? 如何渲染jsx元素多于道具项目(数组) - How to render jsx element more than the props items (array) 接收数据时如何呈现(一次路由安装中呈现多次) - How to render as you recieve data (render more than once in one route mount ) 如何减小超过 600 mb 的 Electron 封装尺寸 - How to reduce Electron package size that exceeds more than 600 mb
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM