FormattersLesson 5Free preview
JSON Stringify
This lesson is part of Web Developer Tools · All levels
Summary
JSON.stringify is a JavaScript function that converts values such as an object or array into JSON strings. This function is used when sending data to a server, storing it in localStorage, or recording log. The second parameter can be a substitution to select a property, while the third parameter regulates the indentation. The values undefined and function do not go into output, and circular references will cause error.
Key points
- Convert JavaScript values to JSON strings that can be sent or stored
- The second parameter (replacer) filters the property or changes the value
- The third parameter (space) regulates the output indentation
- Properties with value undefined or function are removed from the object
- Circular reference causes TypeError
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.