Is there a limit on the size of a string in JSON with Node.js?

后端 未结 4 1405
孤城傲影
孤城傲影 2020-12-03 02:46

A section of my Node.js application involves receiving a string as input from the user and storing it in a JSON file. JSON itself obviously has no limit on this, but is ther

4条回答
  •  清歌不尽
    2020-12-03 03:39

    This is a good question, but I think the upper limit you need to be worried about doesn't involve the max JSON string size.

    In my opinion the limit you need to worry about is how long do you wish to block the request thread while it's processing the user's request.

    Any string size over 1MB will take the user a few seconds to upload and 10 of Megabytes could take minutes. After receiving the request, the server will take a few hundred milliseconds to seconds to parse into a data structure leading to a very poor user experience (Parsing JSON is very expensive)

    The bandwidth and server processing times will overshadow any limit JSON may have on string size.

提交回复
热议问题