当前位置: 首页 > wzjs >正文

如何网页优化深圳债务优化公司

如何网页优化,深圳债务优化公司,网站ui设计报价单,域名购买平台哪个好JSON在线压缩功能&#xff0c;适配所有框架&#xff0c;轻量便捷。支持压缩、格式化、校验功能&#xff0c;并且能标记错误位置&#xff0c;话不多说&#xff0c;上架。。。 <!DOCTYPE html> <html lang"en"> <head> <meta charset"UTF-8&…

        JSON在线压缩功能,适配所有框架,轻量便捷。支持压缩、格式化、校验功能,并且能标记错误位置,话不多说,上架。。。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Editor</title>
<style>body {font-family: Arial, sans-serif;margin: 20px;}.json_edit{width: 100%;}.json_edit .text_contant {width: 100%;height: 300px;border: 1px solid #ccc;padding: 10px;font-size: 14px;outline: none;font-family: monospace;}.json_edit .optionBtn {padding: 10px 15px;margin: 5px;background-color: #007bff;color: #fff;border: none;cursor: pointer;font-size: 14px;}.json_edit #toolTop {margin-top: 20px;padding: 10px;background: #f9f9f9;white-space: pre-wrap;color: #ff4343;}.json_edit .optionBtn:hover {background-color: #0056b3;}.json_edit .error {border: 2px solid #ff4343;background-color: #ffe6e6;}.json_edit .error_content {background-color: #ffcccc;color: #ff4343;font-weight: bold;}.json_edit .line_number {display: inline-block;width: 30px;text-align: right;margin-right: 10px;color: #888;font-size: 13px}</style>
</head>
<body><div class="json_edit"><textarea class="text_contant" id="textareaInput" oninput="clearError()"></textarea><button class="optionBtn" onclick="formatJSON()">格式化JSON</button><button class="optionBtn" onclick="compressJson()">压缩JSON</button><div id="toolTop"></div></div><script>const validJSON = (str) => {try {const obj = JSON.parse(str);return typeof obj === 'object' && obj !== null && (Array.isArray(obj) || Object.prototype.toString.call(obj) === '[object Object]');} catch (e) {return false;}}// 格式化json操作const formatJSON = ()=> {const textareaInput = document.getElementById('textareaInput');const toolTop = document.getElementById('toolTop');if (!textareaInput.value) {return }if (!validJSON(textareaInput.value)) {markError(new Error('JSON格式错误!'), textareaInput);return;}try {const jsonObj = JSON.parse(textareaInput.value);textareaInput.value = JSON.stringify(jsonObj, null, 2);textareaInput.classList.remove('error');toolTop.textContent = '格式化成功!';toolTop.style.color = '#12a793';} catch (error) {markError(error, textareaInput);toolTop.textContent = 'JSON格式错误:' + error.message;toolTop.style.color = '#ff4343';}}// 压缩jsonconst compressJson = ()=> {const textareaInput = document.getElementById('textareaInput');const toolTop = document.getElementById('toolTop');if (!textareaInput.value) {return }if (!validJSON(textareaInput.value)) {markError(new Error('JSON格式错误!'), textareaInput);return;}try {const jsonObj = JSON.parse(textareaInput.value);textareaInput.value = JSON.stringify(jsonObj);textareaInput.classList.remove('error');toolTop.textContent = '压缩成功!';toolTop.style.color = '#12a793';} catch (error) {markError(error, textareaInput);toolTop.textContent = 'JSON格式错误:' + error.message;toolTop.style.color = '#ff4343';}}// 错误提示const markError = (error, textareaInput) => {const toolTop = document.getElementById('toolTop');textareaInput.classList.add('error');let text = textareaInput.value;try {JSON.parse(text);} catch (e) {let match = e.message.match(/position (\d+)/);if (match) {let pos = parseInt(match[1]);let lines = text.substring(0, pos).split('\n');let line = lines.length;let column = lines[lines.length - 1].length + 1;let errorChar = text[pos] || ' ';let formattedText = text.split('\n').map((l, i) => {return `<span class="line_number">${i + 1}</span>${l}`;}).join('\n');let highlightedText = formattedText.substring(0, pos) + '<span class="error_content">' + errorChar + '</span>' + formattedText.substring(pos + 1);toolTop.innerHTML = `JSON格式错误:错误位于第 ${line} 行, 第 ${column} 列<br><br>` + highlightedText;return;}}toolTop.textContent = 'JSON格式错误:' + error.message;toolTop.style.color = '#ff4343';}// 清空errorconst clearError = ()=> {document.getElementById('textareaInput').classList.remove('error');document.getElementById('toolTop').textContent = '';}</script>
</body>
</html>

http://www.dtcms.com/wzjs/518306.html

相关文章:

  • 网站建设熊猫建站百中搜
  • 网站续费如何做分录网络推广的渠道和方式有哪些
  • 做网编去网站还是工作室好seo运营是做什么的
  • 手机上能搭建网站吗搜索引擎原理
  • 越策网站建设网站生成
  • 济南网站建设app百度seo推广计划类型包含
  • 成立公司注册资本需要实缴吗网页seo是什么意思
  • 哪些网站设计的比较好app推广赚钱平台
  • discuz 调用 wordpress北京网站sem、seo
  • 让公司做网站要注意什么在百度做广告多少钱
  • 在线网站软件免费下载安装厦门百度seo点击软件
  • 网站建设找酷风优化措施最新回应
  • 网站开发z亿玛酷1专注bt磁力猪
  • 学习型网站空间郑州seo外包平台
  • 广州电子商务网站建设费用百度推广怎么赚钱
  • 赣州企业网站在那做百度站长号购买
  • 甘肃省住房建设厅网站证书查询新手怎么推广自己的店铺
  • ftp网站后台四年级写一小段新闻
  • 重庆建工集团建设网站哪些网站推广不收费
  • 移动商城网站建设 深圳河南整站百度快照优化
  • 佛山市桂城建设局网站怎么免费建个人网站
  • 广州市建设和水务局网站广州seo网络优化公司
  • 静安区营业执照办理地点整站seo排名费用价格
  • 企业网站优化推广公司超级优化空间
  • 网络规划设计师历年考点百度seo培训公司
  • 网站越来越难做百度点击软件找名风
  • 专门做衣服特卖的网站有哪些广告联盟赚钱app
  • 衡水冀县做网站重庆网站推广专家
  • 地方网站 o2o足球积分排行榜最新
  • 一流的基础微网站开发b站软件推广大全