{"id":1135,"date":"2021-07-30T16:11:07","date_gmt":"2021-07-30T07:11:07","guid":{"rendered":"https:\/\/www.earce.biz\/?page_id=1135"},"modified":"2021-08-04T12:40:29","modified_gmt":"2021-08-04T03:40:29","slug":"tool-json-data-comment","status":"publish","type":"page","link":"https:\/\/www.earce.biz\/?page_id=1135","title":{"rendered":"[Tool] JSON Data Comment"},"content":{"rendered":"\n<p class=\"has-text-align-center wp-block-paragraph\">&lt;&lt; This service is not communicating with the server. &gt;&gt;<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>JSON Data<\/strong><\/p>\n\n\n\n<textarea id=\"textJSON\" rows=\"5\" cols=\"100\" placeholder=\"{\n  &quot;name&quot;: &quot;Alice Brown&quot;,\n  &quot;sku&quot;: &quot;54321&quot;,\n  &quot;price&quot;: 199.95,\n  &quot;shipTo&quot;: {\n    &quot;name&quot;: &quot;Bob Brown&quot;,\n    &quot;address&quot;: &quot;456 Oak Lane&quot;,\n    &quot;city&quot;: &quot;Pretendville&quot;,\n    &quot;state&quot;: &quot;HI&quot;,\n    &quot;zip&quot;: &quot;98999&quot;\n  },\n  &quot;billTo&quot;: {\n    &quot;name&quot;: &quot;Alice Brown&quot;,\n    &quot;address&quot;: &quot;456 Oak Lane&quot;,\n    &quot;city&quot;: &quot;Pretendville&quot;,\n    &quot;state&quot;: &quot;HI&quot;,\n    &quot;zip&quot;: &quot;98999&quot;\n  },\n  &quot;paymentCompletion&quot;: false,\n  &quot;details&quot;: [\n    {\n      &quot;item&quot;: &quot;food&quot;,\n      &quot;price&quot;: 199.95,\n      &quot;prices&quot;: [39.99, 39.99, 39.99, 39.99, 39.99]\n    }\n  ]\n}\"><\/textarea>\n\n\n\n<div class=\"wp-block-button aligncenter custom-wide-button\">\n<button id=\"buttonExec1\" class=\"wp-block-button__link has-background has-vivid-cyan-blue-background-color\">Convert<\/button>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>JSON Comment Template<\/strong><\/p>\n\n\n\n<textarea id=\"textOutput1\" rows=\"10\" cols=\"100\"><\/textarea>\n\n\n\n<script type=\"text\/javascript\">\njQuery().ready(function($){\n\n$(\"#buttonExec1\").click(\n  function(e) {\n    var textJSON = $(\"#textJSON\").val();\n    if (textJSON == \"\") {\n      textJSON = $(\"#textJSON\").attr(\"placeholder\");\n    }\n    var jsonObj = JSON.parse(textJSON);\n\n\n    $('#textOutput1').val(\"\");\n    convertComment(\"\", jsonObj);\n\n    $('#textOutput1').val(JSON.stringify(jsonObj, null, \"\\t\"));\n  }\n);\n\n});\n\nfunction convertComment(prefix, obj) {\n  for (let key in obj) {\n    if (obj[key]==null) {\n      obj[key] = prefix + key + \"_data_comment\" + \" @unknown\";\n    } else if (Array.isArray(obj[key])) {\n      if (obj[key].length > 0) {\n        let cldObj = obj[key][0];\n        obj[key] = [cldObj];\n        if (cldObj!=null) {\n          switch(typeof(cldObj))\n          {\n            case 'string':\n            case 'number':\n            case 'boolean':\n              obj[key] = [key + \"_DataComment\" + \"  \" + prefix + key + \"@\" + typeof(cldObj) + \"\"];\n              break;\n            case 'object':\n              convertComment(prefix + key + \".\", cldObj);\n              break;\n          }\n        }\n      }\n    } else {\n      switch(typeof(obj[key]))\n      {\n        case 'string':\n        case  'number':\n        case  'boolean':\n          obj[key] = key + \"_DataComment\" + \"  \" + prefix + key + \"@\" + typeof(obj[key]) + \"\";\n          break;\n        case 'object':\n          convertComment(prefix + key + \".\", obj[key]);\n          break;\n      }\n    }\n  }\n}\n\n<\/script>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">\u203b<br>JSON\u306e\u30c7\u30fc\u30bf\u9805\u76ee\u3092\u30d3\u30b8\u30e5\u30a2\u30eb\u306a\u5b9a\u7fa9\u306b\u3057\u3088\u3046\u3068\u8003\u3048\u305f\u306e\u3060\u304c\u3001<br>\u3082\u3046JSON\u3067\u305d\u306e\u307e\u307e\u66f8\u3044\u3066Viewer\u3067\u898b\u305f\u65b9\u304c\u65e9\u3044\u306a\u3068\u601d\u3063\u3066\u4f5c\u6210\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u305d\u306e\u969b\u306b\u6570\u5b57\u3068\u304b\u306e\u9805\u76ee\u3092\u6587\u5b57\u578b\u306b\u5909\u66f4\u3057\u305f\u308a\u3001<br>\u968e\u5c64\u306e\u3053\u3068\u3092\u4e00\u500b\u3065\u3064\u66f8\u304f\u306e\u304c\u9762\u5012\u306a\u306e\u3067<br>\u30a8\u30c7\u30a3\u30bf\u3067\u7f6e\u63db\u3057\u3084\u3059\u3044\u3088\u3046\u306b\u6587\u5b57\u3092\u57cb\u3081\u8fbc\u3093\u3067\u6210\u578b\u3057\u306a\u304a\u3059\u3088\u3046\u306b\u3057\u305f\u3082\u306e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;&lt; This service is not communicating with the server. &gt;&gt; JSON Data Convert JSON Comment Template \u203b &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.earce.biz\/?page_id=1135\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;[Tool] JSON Data Comment&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":35,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1135","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/pages\/1135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.earce.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1135"}],"version-history":[{"count":64,"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/pages\/1135\/revisions"}],"predecessor-version":[{"id":1224,"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/pages\/1135\/revisions\/1224"}],"up":[{"embeddable":true,"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/pages\/35"}],"wp:attachment":[{"href":"https:\/\/www.earce.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}