What you didn’t know about JSON.Stringify


This post shows a couple of new tricks and ways to properly leverage the hidden capabilities of JSON.stringify covering: JSON expectations and non-serializable data formats, How to use toJSON() to define objects properly for JSON serialization, The replacer option for filtering out values dynamically, the spaceparameter for formatting JSON output. The post also covers the difference between stringifying arrays and objects containing non-stringifiable fields