Angularjs get request for a huge json file

后端 未结 2 385
没有蜡笔的小新
没有蜡笔的小新 2021-01-18 06:17

I need to display some data from a database to the user. The data is in a json file and has a pretty huge size. The size of json file is roughly around 15MB. I created a ser

相关标签:
2条回答
  • 2021-01-18 06:29

    Based on your requirements of dealing with essentially a huge JSON payload. FWIW you have two options:

    • Your server supports HTTP/JSON streaming:

      create an angular onreadystatechange handler and use a streaming JSON parser like oboe.js

    • Your server DOES NOT support HTTP/JSON streaming

      Do what everyone else is suggesting and provide a paginated access to that payload so that the browser can load it in chunks on demand.

    0 讨论(0)
  • 2021-01-18 06:50

    Make your backend deliver the file in chunks, so that your angular frontend can retrieve part of it at a time.

    Something like:

    /backend/getentries?skip=500&count=100

    The have your frontend repeatedly call the backend while counting up skip and append the results you are getting back to whatever you already have in the frontend.

    0 讨论(0)
提交回复
热议问题