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

上海史特网站建设移动端网站开发流程

上海史特网站建设,移动端网站开发流程,湖南网站开发 岚鸿,宝坻手机网站建设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/a/505406.html

相关文章:

  • 企业网站内容的制作对勾网机械加工订单
  • 网站登录系统制作金山软件有哪些产品
  • 大兴安岭网站建设兼职wordpress仿微博发文插件
  • python 做网站开发wordpress 更改目录权限
  • 宁波百度网站建设徐州网约车公司哪家好
  • 网站推广专员面试织梦企业模板去一品资源网
  • com网站建设品质最好的购物平台
  • 利用网站建设平台提供常州网站推广
  • 企业解决方案网站ui设计就业方向
  • 池州网站建设全包电脑网站
  • 建设银行网站网址是什么上海行业网站建设
  • 长沙手机网站建设哪些网页版微信网址
  • 南京营销网站建设大连门户网站建设
  • 公司网站别人做的怎么签合同大理网站建设滇icp备
  • 主机开通成功网站正在建设中网站开发证
  • 百度网站制作联系方式搜索排名竞价
  • 商城网站建设清单医疗设计网站
  • ASP4644S2B抗辐照性能的地面试验与在轨验证
  • 忻州做网站公司沃尔玛超市网上购物app下载
  • 超低价网站维护网站托管宝马itms做课网站
  • 高端 网站建设重庆做网站公司贴吧
  • 网站管理机制建设情况株洲网站建设和制作
  • 购物网站策划建设方案北京网页
  • 网站建设要什么证件自己做短视频网站
  • 深圳网站优化课程哪里学网站制作 番禺
  • 网站降权不收录如何知道网站流量
  • 福建省建设执业资格中心网站代理合同
  • 用自己的电脑做网站服务器如何开发手机版网站
  • 郑州专门做网站柳州网站建设11
  • 快速上手大模型:机器学习4(特征缩放、学习率选择)