{ "features": { "code": "key_14z65m53jry", "explain": "json 转 markdown", "cmds": [ { "label": " json 转 markdown", "type": "regex", "match": "/^(\\{[\\s\\S]*\\}|\\[[\\s\\S]*\\])$/", "minNum": 1 } ], "icon": "logo/javascript.png", "platform": [ "win32", "darwin", "linux" ] }, "program": "javascript", "cmd": "var jjj = {{ClipText}}\n// jjj = jjj.parseJSON()\n\n\nfunction vtypeof(p){\n if (p == null) {\n return \" \"\n } else {\n switch(p.constructor){\n case Array:return \"array\";break;\n case Object:return \"object\";break;\n default: return typeof(p);\n }\n }\n}\n\nfunction j2m(j, tier) {\n let textArr = []\n symbol = '- - '\n if (j.constructor == Array && j.length > 0) {\n textArr = textArr.concat(j2m(j[0], tier))\n return textArr\n }\n if (j.constructor == Object) {\n for (let key in j) {\n \n var theType = vtypeof (j[key])\n s = \"| \" + symbol.repeat(tier) + key + \" | \" + theType + \" | 无 |\"\n textArr.push(s)\n if (j[key] != null && (j[key].constructor == Array || j[key].constructor == Object)) {\n textArr = textArr.concat(j2m(j[key], tier + 1))\n }\n }\n return textArr\n }\n return textArr\n}\n\nvar t = j2m(jjj, 0)\n\nret = \"|参数|类型|描述|\\n|:-------|:-------|:-------|\\n\"\n\nfor (let key in t) {\n ret += t[key] + \"\\n\"\n}\n\nconsole.log(ret)\n", "output": "send", "hasSubInput": false, "scptarg": "", "charset": { "scriptCode": "", "outputCode": "" }, "tags": [ "string" ]}