「JavaScript/JsonTest」の編集履歴(バックアップ)一覧はこちら
追加された行は緑色になります。
削除された行は赤色になります。
|開発環境|メモ帳|
|実行環境|Internet Explorer 11|
#table_zebra(project, #fff, #eee)
JsonTest.html
#highlight(javascript){{
<html>
<head>
<title>JsonTest</title>
<script type="text/javascript">
<!--
function conv()
{
try {
var obj = JSON.parse(document.f1.src.value);
document.f1.dst.value = JSON.stringify(obj);
}
catch (e) {
document.f1.dst.value = e;
}
}
// -->
</script>
</head>
<body>
<form name="f1">
<textarea name="src" cols=80 rows=10>
{"ary":[0,1,2], "obj":{"a":0,"b":1,"c":2} }
</textarea><br>
<br>
<input type="button" value="↓" onClick="conv()"><br>
<br>
<textarea name="dst" cols=80 rows=10></textarea><br>
</form>
</body>
</html>
}}
|開発環境|メモ帳|
|実行環境|Internet Explorer 11|
#table_zebra(project, #fff, #eee)
JsonTest.html
#highlight(javascript){{
<html>
<head>
<title>JsonTest</title>
<script type="text/javascript">
<!--
function conv()
{
try {
var obj = JSON.parse(document.f1.src.value);
obj.test = true; // 追加テスト
document.f1.dst.value = JSON.stringify(obj);
}
catch (e) {
document.f1.dst.value = e;
}
}
// -->
</script>
</head>
<body>
<form name="f1">
<textarea name="src" cols=80 rows=10>
{"ary":[0,1,2], "obj":{"a":0,"b":1,"c":2} }
</textarea><br>
<br>
<input type="button" value="↓" onClick="conv()"><br>
<br>
<textarea name="dst" cols=80 rows=10></textarea><br>
</form>
</body>
</html>
}}