Skip to content

Instantly share code, notes, and snippets.

@Fasteroid
Last active September 17, 2026 15:08
Show Gist options
  • Select an option

  • Save Fasteroid/c9eba853478da66eb0de477ca623e5d6 to your computer and use it in GitHub Desktop.

Select an option

Save Fasteroid/c9eba853478da66eb0de477ca623e5d6 to your computer and use it in GitHub Desktop.
Parse json structures which might have strings that are also JSON structures, but recursively. Useful for diffing localstorage entries.
function superJsonParse(json){
let nested = json;
if( typeof json === 'string' ) try {
nested = JSON.parse(json);
}
catch(e){}
if( typeof json === 'object' ) for( [k, v] of Object.entries(nested) ){
nested[k] = superJsonParse(v);
}
return nested;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment