首页

序列化 json

用于序列化数据


json

<a class="button" onclick="parse()">序列化</a>
<select id="select">
  <option value="json">json</option>
</select>
<textarea id="textarea" style="width: 100%" cols="30" rows="14"></textarea>
<pre><code id="code" class="javascript"></code></pre>
<script>
  function parse() {
    var code = document.querySelector("#code");
    var text = document.querySelector("#textarea").value;
    console.log(text);
    code.className = document.querySelector("#select").value;
    code.innerHTML = text;
    hljs.highlightBlock(code);
  }
</script>