Just keep it simple if you have localstorage and you want to stringify it use
JSON.stringify(localstorage)
Where localstorage is variable that has localstorage object
jsonString = JSON.stringify(value [, replacer [, space]])
value The JavaScript object to convert into a JSON string.
replacer A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string.
This is the syntax of json.stringify function,its not a callback function