<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Data Format Conversion</title>
    <script>
        window.onload = function() {
            var originalData = {
                "status": 0,
                "message": "",
                "total": 180,
                "data": {
                    "item": [{}, {}]
                }
            };
<pre><code>        var convertedData = {
            &quot;code&quot;: originalData.status,
            &quot;msg&quot;: originalData.message,
            &quot;count&quot;: originalData.total,
            &quot;data&quot;: originalData.data.item
        };

        var convertedDataJson = JSON.stringify(convertedData);

        document.getElementById(&quot;originalData&quot;).innerHTML = JSON.stringify(originalData);
        document.getElementById(&quot;convertedData&quot;).innerHTML = convertedDataJson;
    }
&lt;/script&gt;
</code></pre>
</head>
<body>
    <h1>Data Format Conversion</h1>
    <h2>Original Data:</h2>
    <pre id="originalData"></pre>
    <h2>Converted Data:</h2>
    <pre id="convertedData"></pre>
</body>
</html
status 0 message total 180 data item 以上是数据库返回的数据形式代码实现将数据更改为 code 0 msg count 1000 data 格式编写html实现

原文地址: http://www.cveoy.top/t/topic/iJVM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录