-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSONStringifyExample02.htm
More file actions
executable file
·37 lines (32 loc) · 1020 Bytes
/
Copy pathJSONStringifyExample02.htm
File metadata and controls
executable file
·37 lines (32 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<title>JSON Stringify Example</title>
</head>
<body>
<p>This example serializes an object and passes in a filter function.</p>
<script type="text/javascript">
var book = {
title: "Professional JavaScript",
authors: [
"Nicholas C. Zakas"
],
edition: 3,
year: 2011
};
var jsonText = JSON.stringify(book, function(key, value){
switch(key){
case "authors":
return value.join(",")
case "year":
return 5000;
case "edition":
return undefined;
default:
return value;
}
});
alert(jsonText);
</script>
</body>
</html>