{"id":31459,"date":"2024-11-25T10:09:42","date_gmt":"2024-11-25T02:09:42","guid":{"rendered":"https:\/\/fwq.ai\/blog\/31459\/"},"modified":"2024-11-25T10:09:42","modified_gmt":"2024-11-25T02:09:42","slug":"json%e5%af%b9%e8%b1%a1%e7%9a%84%e5%a4%a7%e5%b0%8f%e5%86%99%e8%bd%ac%e6%8d%a2%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/31459\/","title":{"rendered":"json\u5bf9\u8c61\u7684\u5927\u5c0f\u5199\u8f6c\u6362\u65b9\u6cd5"},"content":{"rendered":"<p style=\"text-align: left\">\u8fd9\u6b21\u7ed9\u5927\u5bb6\u5e26\u6765json\u7684\u5927\u5c0f\u5199\u8f6c\u6362\u65b9\u6cd5\uff0cjson\u5bf9\u8c61\u5927\u5c0f\u5199\u8f6c\u6362\u7684\u6709\u54ea\u4e9b\uff0c\u4e0b\u9762\u5c31\u662f\u5b9e\u6218\u6848\u4f8b\uff0c\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u3002<\/p>\n<p style=\"text-align: left\"><span style=\"color: #ff0000\"><strong>\u524d\u8a00<\/strong><\/span><\/p>\n<p style=\"text-align: left\">\u6700\u8fd1\u5728\u505a\u4e00\u4e2a\u9879\u76ee\uff0c\u53d1\u73b0\u540e\u7aef\u8fd4\u56de\u7684\u6570\u636e\u952e\u503c\u5168\u90e8\u90fd\u662f\u5927\u5199\u7684\uff0c\u6709\u65f6\u5019\u524d\u7aef\u7528\u8d77\u6765\u5f88\u4e0d\u65b9\u4fbf\uff0c\u6240\u4ee5\u5199\u4e86\u4e00\u4e2a\u6df1\u5ea6\u8f6c\u6362\u7684\u5c0f\u5de5\u5177\uff0c\u5206\u4eab\u7ed9\u5927\u5bb6\uff0c\u4e5f\u5c31\u4e0d\u7528\u91cd\u590d\u9020\u8f6e\u5b50\u4e86\uff0c\u4e0d\u559c\u52ff\u55b7\uff0c\u4e0b\u9762\u8bdd\u4e0d\u591a\u8bf4\u4e86\uff0c\u6765\u4e00\u8d77\u770b\u770b\u8be6\u7ec6\u7684\u4ecb\u7ecd\u5427\u3002<\/p>\n<p style=\"text-align: left\"><span style=\"color: #ff0000\"><strong>start<\/strong><\/span><\/p>\n<pre>npm i deep-lu-trans --save<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align: left\"><span style=\"color: #ff0000\"><strong>json example<\/strong><\/span><\/p>\n<pre>import t from 'deep-lu-trans';\r\nconst obj = {\r\n AS_DD_S: 123213,\r\n AND_SAJ_JDK_JSAKD_: {\r\n DJK_ASJ: {\r\n  SA_DSA_DSA: 123123,\r\n  ASDA_SDH_KAS: {\r\n  ASD_SAD: [{\r\n   ASD_SAD_SA: 123123,\r\n   III_ASDA: [1, 23, {\r\n   ASD_SAD: 123\r\n   }]\r\n  }]\r\n  }\r\n }\r\n },\r\n KIO: [{\r\n OP: 1,\r\n OOP: 2\r\n }, {\r\n OL: 1,\r\n OP: 2\r\n }]\r\n};\r\nt.objKeysToLower(obj).then((res) =&gt; {\r\n console.log(JSON.stringify(res));\r\n});\r\nt.objKeysToLower(obj).then((res) =&gt; {\r\n console.log(JSON.stringify(res));\r\n \/*\r\n {\"as_dd_s\":123213,\"and_saj_jdk_jsakd_\":{\"djk_asj\":{\"sa_dsa_dsa\":123123,\"asda_sdh_kas\":{\"asd_sad\":[{\"asd_sad_sa\":123123,\"iii_asda\":[1,23,{\"asd_sad\":123}]}]}}},\"kio\":[{\"op\":1,\"oop\":2},{\"ol\":1,\"op\":2}]}\r\n *\/\r\n t.objKeysToUpper(res).then((_s) =&gt; {\r\n console.log(JSON.stringify(_s));\r\n \/*\r\n {\"AS_DD_S\":123213,\"AND_SAJ_JDK_JSAKD_\":{\"DJK_ASJ\":{\"SA_DSA_DSA\":123123,\"ASDA_SDH_KAS\":{\"ASD_SAD\":[{\"ASD_SAD_SA\":123123,\"III_ASDA\":[1,23,{\"ASD_SAD\":123}]}]}}},\"KIO\":[{\"OP\":1,\"OOP\":2},{\"OL\":1,\"OP\":2}]}\r\n  *\/\r\n });\r\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align: left\"><span style=\"color: #ff0000\"><strong> example<\/strong><\/span><\/p>\n<pre>import t from 'deep-lu-trans';\r\nconst arr = [{\r\n A_B: 1,\r\n B_C: 2\r\n}, 3, 4, 'abc', [{\r\n A_B: 1,\r\n B_C: {\r\n C_D: [0, {\r\n  CK: 1,\r\n  KL: 2\r\n }]\r\n }\r\n}]]\r\nt.arrKeysToLower(arr).then((res) =&gt; {\r\n console.log(JSON.stringify(res));\r\n \/*\r\n [{\"a_b\":1,\"b_c\":2},3,4,\"abc\",[{\"a_b\":1,\"b_c\":{\"c_d\":[0,{\"ck\":1,\"kl\":2}]}}]]\r\n *\/\r\n t.arrKeysToUpper(res).then((_s) =&gt; {\r\n console.log(JSON.stringify(_s));\r\n [{\"A_B\":1,\"B_C\":2},3,4,\"abc\",[{\"A_B\":1,\"B_C\":{\"C_D\":[0,{\"CK\":1,\"KL\":2}]}}]]\r\n });\r\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align: left\">\n<p>\u76f8\u4fe1\u770b\u4e86\u672c\u6587\u6848\u4f8b\u4f60\u5df2\u7ecf\u638c\u63e1\u4e86\u65b9\u6cd5\uff0c\u66f4\u591a\u7cbe\u5f69\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n<p>\u63a8\u8350\u9605\u8bfb\uff1a<\/p>\n<p><\/p>\n<p><\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjson\u5bf9\u8c61\u7684\u5927\u5c0f\u5199\u8f6c\u6362\u65b9\u6cd5\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u6b21\u7ed9\u5927\u5bb6\u5e26\u6765json\u7684\u5927\u5c0f\u5199\u8f6c\u6362\u65b9\u6cd5\uff0cjson\u5bf9\u8c61\u5927\u5c0f\u5199\u8f6c\u6362\u7684\u6709\u54ea\u4e9b\uff0c\u4e0b\u9762\u5c31\u662f\u5b9e\u6218\u6848\u4f8b\uff0c\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u3002 \u524d\u8a00 \u6700\u8fd1\u5728\u505a\u4e00\u4e2a\u9879\u76ee\uff0c\u53d1\u73b0\u540e\u7aef\u8fd4\u56de\u7684\u6570\u636e\u952e\u503c\u5168\u90e8\u90fd\u662f\u5927\u5199\u7684\uff0c\u6709\u65f6\u5019\u524d\u7aef\u7528\u8d77\u6765\u5f88\u4e0d\u65b9\u4fbf\uff0c\u6240\u4ee5\u5199\u4e86\u4e00\u4e2a\u6df1\u5ea6\u8f6c\u6362\u7684\u5c0f\u5de5\u5177\uff0c\u5206\u4eab\u7ed9\u5927\u5bb6\uff0c\u4e5f\u5c31\u4e0d\u7528\u91cd\u590d\u9020\u8f6e\u5b50\u4e86\uff0c\u4e0d\u559c\u52ff\u55b7\uff0c\u4e0b\u9762\u8bdd\u4e0d\u591a\u8bf4\u4e86\uff0c\u6765\u4e00\u8d77\u770b\u770b\u8be6\u7ec6\u7684\u4ecb\u7ecd\u5427\u3002 start npm i deep-lu-trans &#8211;save \u767b\u5f55\u540e\u590d\u5236 json example import t from &#8216;deep-lu-trans&#8217;; const obj = { AS_DD_S: 123213, AND_SAJ_JDK_JSAKD_: { DJK_ASJ: { SA_DSA_DSA: 123123, ASDA_SDH_KAS: { ASD_SAD: [{ ASD_SAD_SA: 123123, III_ASDA: [1, 23, { ASD_SAD: 123 }] }] } } }, KIO: [{ OP: 1, OOP: 2 }, { OL: 1, OP: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-31459","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=31459"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31459\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=31459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=31459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=31459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}