[英]What's the easiest way to format web-based data by content, CSS, Javascript, or other method?
[英]What is the easiest way to format json data in a text box on a web page?
我目前在一些网页上使用edit_area_full.js格式化python代码示例。 我有几种情况需要格式化json数据,但edit_area不支持json。 可以在网页的文本框中格式化json数据的edit_area替代品的最佳选择是什么?
这是我格式化python代码的方式。
<p><textarea id="code-area" name="user_code" rows="12" cols="80">if True: pass</textarea></p>
<script language="javascript" type="text/javascript" src="/static/edit_area_full.js"></script>
<script language="javascript" type="text/javascript">
editAreaLoader.init({
id: "code-area",
syntax: "python",
start_highlight: true,
allow_resize: "no",
font_size: 12,
toolbar: "new_document, |, help",
replace_tab_by_spaces: 4
});
</script>
您可以使用:
您可以在这里测试工作中的更高版本的库: http : //jsbeautifier.org/
例如,我喂它:
var testvar = {asd:[abc,cde,fg,{hello: world},1,2,3],ccc:"aaa",ddd:33,cas:[qwerty,[1,[2],3],4]};
并得到以下结果:
var testvar = {
asd: [abc, cde, fg, {
hello: world
}, 1, 2, 3],
ccc: "aaa",
ddd: 33,
cas: [qwerty, [1, [2], 3], 4]
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.