My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

What is the best way to calculate the size of a JSON object in Node.js?

Jeremy Wright's photo
Jeremy Wright
·Apr 28, 2016

My API consumes JSON and saves it in a record. However, I would like to impose a size limit on the object. For example, in MongoDB the document size must be less than 16MB. How should I go about it in Node.js?