mirror of
https://github.com/donl/JSON-js.git
synced 2026-06-30 06:11:58 -06:00
&&
This commit is contained in:
parent
2a76286e00
commit
58df70e97f
3 changed files with 424 additions and 7 deletions
36
test.html
Normal file
36
test.html
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<html><body><script src="cycle.js"></script>
|
||||
<pre><p id=output></p>
|
||||
<script>
|
||||
function out(s) {
|
||||
document.getElementById('output').innerHTML += s + '<br>';
|
||||
}
|
||||
|
||||
function doTest() {
|
||||
var i, o, s, jsonObj;
|
||||
try {
|
||||
o = {
|
||||
number: 98.6,
|
||||
string: 'Why is it called string?'
|
||||
};
|
||||
o.object = o;
|
||||
o.array = [o];
|
||||
out(JSON.stringify(JSON.decycle(
|
||||
[o, o],
|
||||
function (value) {
|
||||
if (typeof value === 'string') {
|
||||
return 'because';
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
)));
|
||||
|
||||
} catch (e) {
|
||||
debugger;
|
||||
out(" name: " + e.name);
|
||||
out(" message: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
doTest();
|
||||
</script></pre></body></html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue