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

+26
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)