JosnIndex.cshtml
1.65 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
@{ Layout = "~/Views/Shared/_Layout.cshtml"; }
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@section header
{
<link href="~/css/homecss/bootstrap.min.css" rel="stylesheet" />
<link href="~/js/json/jquery.json-viewer.css" rel="stylesheet" />
<style type="text/css">
#json-renderer {
height: 400px;
overflow-y: auto;
}
</style>
}
<div class="container" style="margin-top: 1em;">
<div class="row">
<textarea class="form-control" id="json-input" rows="5" placeholder="请输入正确的json格式数据"></textarea>
<label class="checkbox-inline">
<input type="checkbox" id="collapsed">收缩所有的节点
</label>
<div class="form-group">
<button id="btn-json-viewer" class="btn btn-info" title="run jsonViewer()">转换Json数据</button>
</div>
<pre id="json-renderer"></pre>
</div>
</div>
@section Scripts
{
<script src="~/js/jQuery-2.1.4.min.js"></script>
<script src="~/js/json/jquery.json-viewer.js"></script>
<script>
$(function () {
$('#btn-json-viewer').click(function () {
try {
var input = eval('(' + $('#json-input').val() + ')');
}
catch (error) {
return alert("Cannot eval JSON: " + error);
}
var options = {
collapsed: $('#collapsed').is(':checked'),
withQuotes: $('#with-quotes').is(':checked')
};
$('#json-renderer').jsonViewer(input, options);
});
});
</script>
}