{"id":297,"date":"2021-01-15T14:53:39","date_gmt":"2021-01-15T06:53:39","guid":{"rendered":"https:\/\/22pig.com\/?p=297"},"modified":"2021-01-15T14:53:39","modified_gmt":"2021-01-15T06:53:39","slug":"java%e4%b8%adjson%e8%bd%ac%e6%8d%a2bean%e5%af%b9%e8%b1%a1%e5%b9%b6%e5%bf%bd%e7%95%a5%e5%a4%a7%e5%b0%8f%e5%86%99%ef%bc%81","status":"publish","type":"post","link":"http:\/\/22pig.com\/?p=297","title":{"rendered":"Java\u4e2dJson\u8f6c\u6362Bean\u5bf9\u8c61\u5e76\u5ffd\u7565\u5927\u5c0f\u5199\uff01"},"content":{"rendered":"<p>import com.sdzn.vo.ICPostJsonBeanVO;<\/p>\n<p>public class test {<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>String tString = &#8220;{\\&#8221;FuncName\\&#8221;:\\&#8221;UploadGroupInfo\\&#8221;,\\&#8221;ParamNum\\&#8221;:\\&#8221;1\\&#8221;,\\&#8221;ParamValue\\&#8221;:\\&#8221;444\\&#8221;}&#8221;;<\/p>\n<p>JSONObject jsonObj1 = JSONObject.fromObject(tString);<\/p>\n<p>JsonConfig config = new JsonConfig();<\/p>\n<p>config.setJavaIdentifierTransformer(new JavaIdentifierTransformer() {<\/p>\n<p>@Override<br \/>\npublic String transformToJavaIdentifier(String str) {<\/p>\n<p>char[] chars = str.toCharArray();<\/p>\n<p>chars[0] = Character.toLowerCase(chars[0]);<\/p>\n<p>return new String(chars);<\/p>\n<p>}<\/p>\n<p>});<\/p>\n<p>config.setRootClass(ICPostJsonBeanVO.class);<\/p>\n<p>ICPostJsonBeanVO p2 = (ICPostJsonBeanVO) JSONObject.toBean(jsonObj1,<br \/>\nconfig);<\/p>\n<p>System.out.println(&#8220;json\u8f6c\u5316\u4e3a\u5bf9\u8c61\uff1a\u65b9\u6cd5\u540d\uff1a&#8221; + p2.getFuncName() + &#8220;;\u6570\u91cf:&#8221;<br \/>\n+ p2.getParamNum() + &#8220;\u503c\uff1a&#8221; + p2.getParamValue());<\/p>\n<p>}<\/p>\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>import com.sdzn.vo.ICPostJsonBeanVO; public class test { public static void main(String[] args) { String tString = &#8220;{\\&#8221;FuncName\\&#8221;:\\&#8221;UploadGroupInfo\\&#8221;,\\&#8221;ParamNum\\&#8221;:\\&#8221;1\\&#8221;,\\&#8221;ParamValue\\&#8221;:\\&#8221;444\\&#8221;}&#8221;; JSONObject jsonObj1 = JSONObject.fromObject(tString); JsonConfig config = new JsonConfig(); config.setJavaIdentifierTransformer(new JavaIdentifierTransformer() { @Override public String transformToJavaIdentifier(String str) { char[] chars = str.toCharArray(); chars[0] = Character.toLowerCase(chars[0]); return new String(chars); } }); config.setRootClass(ICPostJsonBeanVO.class); ICPostJsonBeanVO p2 = (ICPostJsonBeanVO) JSONObject.toBean(jsonObj1, config); System.out.println(&#8220;json\u8f6c\u5316\u4e3a\u5bf9\u8c61\uff1a\u65b9\u6cd5\u540d\uff1a&#8221; + &#8230; <a title=\"Java\u4e2dJson\u8f6c\u6362Bean\u5bf9\u8c61\u5e76\u5ffd\u7565\u5927\u5c0f\u5199\uff01\" class=\"read-more\" href=\"http:\/\/22pig.com\/?p=297\" aria-label=\"More on Java\u4e2dJson\u8f6c\u6362Bean\u5bf9\u8c61\u5e76\u5ffd\u7565\u5927\u5c0f\u5199\uff01\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-297","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"http:\/\/22pig.com\/index.php?rest_route=\/wp\/v2\/posts\/297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/22pig.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/22pig.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/22pig.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/22pig.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=297"}],"version-history":[{"count":0,"href":"http:\/\/22pig.com\/index.php?rest_route=\/wp\/v2\/posts\/297\/revisions"}],"wp:attachment":[{"href":"http:\/\/22pig.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/22pig.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=297"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/22pig.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}