{"id":5227,"date":"2019-08-22T11:08:19","date_gmt":"2019-08-22T03:08:19","guid":{"rendered":"http:\/\/www.hefeiyu.com\/?p=5227"},"modified":"2019-08-22T11:08:19","modified_gmt":"2019-08-22T03:08:19","slug":"t100-%e5%af%b9json%e3%80%81array%e7%9a%84%e9%81%8d%e5%8e%86%e8%af%bb%e5%86%99","status":"publish","type":"post","link":"https:\/\/www.hefeiyu.com\/?p=5227","title":{"rendered":"T100\u2014\u2014\u5bf9JSON\u3001ARRAY\u7684\u904d\u5386\u8bfb\u5199"},"content":{"rendered":"<p>jsonArray\u662f[]\u7684\uff0cjson\u662f{}\u7684<\/p>\n<p>\u4f8b\u5982<\/p>\n<p>JSON\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">{\r\n\r\n\"Id\":{\"value\":\"da30d681-fab0-4e80-9dd8-137b2b4470ea\",\"text\":\"da30d681-fab0-4e80-9dd8-137b2b4470ea\",\"css\":{}}\r\n\r\n}<\/code><\/pre>\n<p>T100\u5199JSON\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">DEFINE l_json    util.JSONObject\r\nDEFINE rec RECORD\r\n\r\n               value STRING,\r\n\r\n               text  STRING,\r\n\r\n               css   util.JSONObject\r\n\r\n           END RECORD\r\n\r\nLET l_json = util.JSONObject.parse(p_str)    \r\n    FOR i=1 TO l_json.getLength()\r\n        IF l_json.name(i) = \"Id\" THEN\r\n           LET rec.value = p_id\r\n           LET rec.text = p_id\r\n           LET rec.css = util.JSONObject.parse(\"{}\")\r\n           CALL l_json.put(l_json.name(i),rec)\r\n           CONTINUE FOR\r\n        END IF\r\n\r\n  END FOR<\/code><\/pre>\n<p>T100\u8bfbJSON\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">###\u83b7\u53d6STRING\u91cc\u7684\u5185\u7801Id\r\nDEFINE p_str   STRING\r\n###\r\nDEFINE l_json   util.JSONObject\r\nDEFINE l_json2   util.JSONObject\r\nDEFINE i    INTEGER\r\nDEFINE r_id STRING\r\n    INITIALIZE r_id TO NULL\r\n    IF NOT cl_null(p_str) THEN\r\n        #\u89e3\u6790JSON\r\n        LET l_json = util.JSONObject.parse(p_str)   \r\n        FOR i=1 TO l_json.getLength()   #\u904d\u53861\r\n            IF l_json.name(i) = \"Id\" THEN\r\n                LET l_json2 = l_json.get(l_json.name(i)) \r\n                LET r_id = l_json2.get(\"value\")\r\n                EXIT FOR\r\n            END IF\r\n        END FOR\r\n        RETURN r_id\r\n    ELSE\r\n        RETURN NULL\r\n    END IF<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.hefeiyu.com\">\u8d6b\u975e\u57df<\/a> &raquo; <a href=\"https:\/\/www.hefeiyu.com\/?p=5227\">T100\u2014\u2014\u5bf9JSON\u3001ARRAY\u7684\u904d\u5386\u8bfb\u5199<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>jsonArray\u662f[]\u7684\uff0cjson\u662f{}\u7684 \u4f8b\u5982 JSON\uff1a { &#8220;Id&#8221;:{&#8220;value&#8221;:&#8221;da30d681-fab0-4e80-9dd8-137b2b4470ea&#8221;,&#8221;text&#8221;:&#8221;da30d681-fab0-4e80-9dd8-137b2b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[490],"tags":[770,773,772],"class_list":["post-5227","post","type-post","status-publish","format-standard","hentry","category-490","tag-json","tag-jsonobject","tag-util"],"_links":{"self":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/5227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5227"}],"version-history":[{"count":1,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/5227\/revisions"}],"predecessor-version":[{"id":5228,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/5227\/revisions\/5228"}],"wp:attachment":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}