Last active
September 17, 2026 15:08
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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