Skip to content

Commit b29c5bc

Browse files
authored
JSON.stringify keys to serialize.
1 parent 345f6cd commit b29c5bc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,29 @@ console.log(globalThis) //get the global this depends on your environment
431431
```
432432
433433
434+
435+
# The second argument of JSON.stringify lets you cherry-pick 🍒 keys to serialize.
436+
```javascript
437+
const user = {
438+
id: 459,
439+
name: 'JS snippets',
440+
age:29,
441+
education:{
442+
degree: 'Masters'
443+
}
444+
}
445+
446+
JSON.stringify(user,[name,age], 2)
447+
448+
/*
449+
returns
450+
451+
{
452+
"name": "JS snippets",
453+
"age": 29
454+
}
455+
456+
457+
*/
458+
459+
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy