{"id":59585,"date":"2026-01-14T07:25:49","date_gmt":"2026-01-13T23:25:49","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/59585.html"},"modified":"2026-01-14T07:25:49","modified_gmt":"2026-01-13T23:25:49","slug":"c-c-%e4%bd%bf%e7%94%a8cjson%e5%ba%93%e5%ae%9e%e7%8e%b0%e7%bb%93%e6%9e%84%e4%bd%93%e5%92%8cjson%e5%ad%97%e7%ac%a6%e4%b8%b2%e7%9b%b8%e4%ba%92%e5%ba%8f%e5%88%97%e5%8c%96","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/59585.html","title":{"rendered":"C\/C++ \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316"},"content":{"rendered":"<\/p>\n<h4>C\/C&#043;&#043; \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316<\/h4>\n<ul>\n<li>\u4e00\u3001\u4ec0\u4e48\u662fjson<\/li>\n<li>\n<ul>\n<li>1\u3001\u6838\u5fc3\u7279\u6027<\/li>\n<li>2\u3001\u5e94\u7528\u573a\u666f<\/li>\n<li>3\u3001\u793a\u4f8b\u89e3\u6790<\/li>\n<li>4\u3001\u6ce8\u610f\u4e8b\u9879<\/li>\n<\/ul>\n<\/li>\n<li>\u4e8c\u3001cJSON\u5e93\u4ecb\u7ecd<\/li>\n<li>\n<ul>\n<li>1\u3001 \u6982\u8ff0<\/li>\n<li>2\u3001 \u6838\u5fc3\u529f\u80fd<\/li>\n<li>3\u3001\u4e3b\u8981\u7279\u70b9<\/li>\n<li>4\u3001 \u6570\u636e\u7ed3\u6784<\/li>\n<li>5\u3001\u57fa\u672c\u4f7f\u7528\u6d41\u7a0b<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u4e92\u8f6c<\/li>\n<li>\n<ul>\n<li>1\u3001\u4e0b\u8f7d\u6e90\u7801<\/li>\n<li>2\u3001\u4f7f\u7528\u65b9\u6cd5<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260113232547-6966d47babd8e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u4e00\u3001\u4ec0\u4e48\u662fjson<\/h2>\n<p>JSON&#xff08;JavaScript Object Notation&#xff09;\u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f&#xff0c;\u5e38\u7528\u4e8e\u7f51\u7edc\u6570\u636e\u4f20\u8f93\u548c\u914d\u7f6e\u6587\u4ef6\u3002\u5b83\u91c7\u7528\u4eba\u7c7b\u53ef\u8bfb\u7684\u6587\u672c\u683c\u5f0f&#xff0c;\u57fa\u4e8eJavaScript\u5bf9\u8c61\u8bed\u6cd5&#xff0c;\u4f46\u72ec\u7acb\u4e8e\u7f16\u7a0b\u8bed\u8a00&#xff08;\u51e0\u4e4e\u6240\u6709\u4e3b\u6d41\u8bed\u8a00\u90fd\u652f\u6301JSON\u89e3\u6790&#xff09;\u3002<\/p>\n<h3>1\u3001\u6838\u5fc3\u7279\u6027<\/h3>\n<li>\n<p>\u7ed3\u6784\u6e05\u6670<\/p>\n<ul>\n<li>\u952e\u503c\u5bf9\u96c6\u5408&#xff1a;{ &#034;name&#034;: &#034;Alice&#034;, &#034;age&#034;: 30 }<\/li>\n<li>\u6709\u5e8f\u5217\u8868&#xff1a;[ &#034;apple&#034;, &#034;banana&#034;, &#034;cherry&#034; ]<\/li>\n<li>\u652f\u6301\u5d4c\u5957&#xff1a;<span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token string-property property\">&#034;user&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string-property property\">&#034;id&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token number\">123<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token string-property property\">&#034;preferences&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;reading&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;hiking&#034;<\/span><span class=\"token punctuation\">]<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span>\n <\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u6570\u636e\u7c7b\u578b<\/p>\n<ul>\n<li>\u5b57\u7b26\u4e32&#xff1a;&#034;hello&#034;<\/li>\n<li>\u6570\u5b57&#xff1a;42 \u6216 3.14<\/li>\n<li>\u5e03\u5c14\u503c&#xff1a;true\/false<\/li>\n<li>\u7a7a\u503c&#xff1a;null<\/li>\n<li>\u6570\u7ec4&#xff1a;[1, 2, 3]<\/li>\n<li>\u5bf9\u8c61&#xff1a;{&#034;key&#034;: &#034;value&#034;}<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u8bed\u6cd5\u89c4\u5219<\/p>\n<ul>\n<li>\u952e\u540d\u5fc5\u987b\u7528\u53cc\u5f15\u53f7\u5305\u88f9<\/li>\n<li>\u5b57\u7b26\u4e32\u5fc5\u987b\u7528\u53cc\u5f15\u53f7<\/li>\n<li>\u4e0d\u5141\u8bb8\u6ce8\u91ca\u6216\u5c3e\u968f\u9017\u53f7<\/li>\n<\/ul>\n<\/li>\n<h3>2\u3001\u5e94\u7528\u573a\u666f<\/h3>\n<ul>\n<li>API\u901a\u4fe1&#xff1a;\u524d\u540e\u7aef\u6570\u636e\u4ea4\u4e92&#xff08;\u5982RESTful API&#xff09;<\/li>\n<li>\u914d\u7f6e\u6587\u4ef6&#xff1a;package.json&#xff08;Node.js&#xff09;\u3001tsconfig.json&#xff08;TypeScript&#xff09;<\/li>\n<li>\u6570\u636e\u5b58\u50a8&#xff1a;NoSQL\u6570\u636e\u5e93&#xff08;\u5982MongoDB&#xff09;\u7684\u6587\u6863\u683c\u5f0f<\/li>\n<li>\u65e5\u5fd7\u8bb0\u5f55&#xff1a;\u7ed3\u6784\u5316\u65e5\u5fd7\u6587\u4ef6<\/li>\n<\/ul>\n<h3>3\u3001\u793a\u4f8b\u89e3\u6790<\/h3>\n<p><span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token string-property property\">&#034;course&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;\u8ba1\u7b97\u673a\u79d1\u5b66&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token string-property property\">&#034;credits&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token number\">4<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token string-property property\">&#034;prerequisites&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;\u7f16\u7a0b\u57fa\u7840&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u79bb\u6563\u6570\u5b66&#034;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token string-property property\">&#034;active&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5bf9\u5e94JavaScript\u5bf9\u8c61&#xff1a;<\/p>\n<p><span class=\"token keyword\">const<\/span> courseInfo <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token literal-property property\">course<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;\u8ba1\u7b97\u673a\u79d1\u5b66&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token literal-property property\">credits<\/span><span class=\"token operator\">:<\/span> <span class=\"token number\">4<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token literal-property property\">prerequisites<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;\u7f16\u7a0b\u57fa\u7840&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u79bb\u6563\u6570\u5b66&#034;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token literal-property property\">active<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h3>4\u3001\u6ce8\u610f\u4e8b\u9879<\/h3>\n<li>\u5b89\u5168\u98ce\u9669 \u76f4\u63a5\u89e3\u6790\u4e0d\u53ef\u4fe1\u6765\u6e90\u7684JSON\u53ef\u80fd\u5bfc\u81f4\u6ce8\u5165\u653b\u51fb&#xff08;\u5982JSON.parse()\u6267\u884c\u6076\u610f\u4ee3\u7801&#xff09;\u3002<\/li>\n<li>\u683c\u5f0f\u6821\u9a8c \u4f7f\u7528\u5de5\u5177\u5982JSON Schema\u9a8c\u8bc1\u7ed3\u6784\u5408\u6cd5\u6027\u3002<\/li>\n<li>\u89e3\u6790\u5dee\u5f02 \u67d0\u4e9b\u8bed\u8a00&#xff08;\u5982Python&#xff09;\u7684json\u6a21\u5757\u4f1a\u5c06\u6570\u5b57\u89e3\u6790\u4e3a\u6d6e\u70b9\u6570\u800c\u975e\u6574\u6570\u3002<\/li>\n<h2>\u4e8c\u3001cJSON\u5e93\u4ecb\u7ecd<\/h2>\n<h3>1\u3001 \u6982\u8ff0<\/h3>\n<p>cJSON \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u3001\u5f00\u6e90\u7684 C \u8bed\u8a00 JSON \u89e3\u6790\u5e93\u3002\u5b83\u4e13\u6ce8\u4e8e\u63d0\u4f9b\u7b80\u5355\u3001\u5feb\u901f\u4e14\u6613\u4e8e\u4f7f\u7528\u7684\u63a5\u53e3&#xff0c;\u7528\u4e8e\u5728 C \u8bed\u8a00\u7a0b\u5e8f\u4e2d\u89e3\u6790\u3001\u751f\u6210\u548c\u64cd\u4f5c JSON (JavaScript Object Notation) \u6570\u636e\u3002JSON \u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f&#xff0c;\u5e7f\u6cdb\u7528\u4e8e\u7f51\u7edc\u901a\u4fe1\u3001\u914d\u7f6e\u6587\u4ef6\u5b58\u50a8\u7b49\u573a\u666f\u3002<\/p>\n<h3>2\u3001 \u6838\u5fc3\u529f\u80fd<\/h3>\n<p>cJSON \u63d0\u4f9b\u4ee5\u4e0b\u6838\u5fc3\u529f\u80fd&#xff1a;<\/p>\n<ul>\n<li>\u89e3\u6790 JSON: \u5c06 JSON \u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u89e3\u6790\u6210 cJSON \u63d0\u4f9b\u7684\u6570\u636e\u7ed3\u6784&#xff08;\u901a\u5e38\u662f cJSON \u5bf9\u8c61&#xff09;&#xff0c;\u4ee5\u4fbf\u7a0b\u5e8f\u80fd\u591f\u8bfb\u53d6\u5176\u4e2d\u7684\u6570\u636e\u3002<\/li>\n<li>\u751f\u6210 JSON: \u5c06\u7a0b\u5e8f\u4e2d\u7684\u6570\u636e\u7ed3\u6784&#xff08;cJSON \u5bf9\u8c61&#xff09;\u5e8f\u5217\u5316\u6210\u7b26\u5408 JSON \u89c4\u8303\u7684\u5b57\u7b26\u4e32&#xff0c;\u4fbf\u4e8e\u4f20\u8f93\u6216\u5b58\u50a8\u3002<\/li>\n<li>\u8bbf\u95ee\u6570\u636e: \u63d0\u4f9b API \u7528\u4e8e\u904d\u5386\u548c\u8bbf\u95ee\u89e3\u6790\u540e\u7684 JSON \u5bf9\u8c61\u4e2d\u7684\u952e\u503c\u5bf9\u3001\u6570\u7ec4\u5143\u7d20\u7b49\u3002<\/li>\n<li>\u4fee\u6539\u6570\u636e: \u652f\u6301\u5728\u89e3\u6790\u540e\u7684\u7ed3\u6784\u4f53\u4e0a\u6dfb\u52a0\u3001\u4fee\u6539\u6216\u5220\u9664\u5143\u7d20\u3002<\/li>\n<li>\u6253\u5370\u683c\u5f0f\u5316: \u53ef\u4ee5\u5c06 cJSON \u5bf9\u8c61\u4ee5\u683c\u5f0f\u5316\u7684&#xff08;\u6613\u8bfb&#xff09;\u6216\u975e\u683c\u5f0f\u5316\u7684&#xff08;\u7d27\u51d1&#xff09;\u65b9\u5f0f\u6253\u5370\u6210 JSON \u5b57\u7b26\u4e32\u3002<\/li>\n<\/ul>\n<h3>3\u3001\u4e3b\u8981\u7279\u70b9<\/h3>\n<ul>\n<li>\u8f7b\u91cf\u7ea7: cJSON \u7684\u6e90\u4ee3\u7801\u975e\u5e38\u7cbe\u7b80&#xff0c;\u901a\u5e38\u53ea\u6709\u4e00\u4e2a .c \u6587\u4ef6\u548c\u4e00\u4e2a .h \u5934\u6587\u4ef6\u3002\u8fd9\u4f7f\u5f97\u5b83\u6613\u4e8e\u96c6\u6210\u5230\u9879\u76ee\u4e2d&#xff0c;\u5c24\u5176\u9002\u5408\u8d44\u6e90\u53d7\u9650\u7684\u73af\u5883&#xff08;\u5982\u5d4c\u5165\u5f0f\u7cfb\u7edf&#xff09;\u3002<\/li>\n<li>\u7eaf C \u5b9e\u73b0: \u5b8c\u5168\u7528 C \u8bed\u8a00\u7f16\u5199&#xff0c;\u4e0d\u4f9d\u8d56\u5916\u90e8\u5e93&#xff08;\u9664\u6807\u51c6 C \u5e93\u5916&#xff09;&#xff0c;\u5177\u6709\u826f\u597d\u7684\u53ef\u79fb\u690d\u6027\u3002<\/li>\n<li>\u7b80\u5355\u6613\u7528: API \u8bbe\u8ba1\u76f8\u5bf9\u7b80\u6d01\u660e\u4e86\u3002\u6838\u5fc3\u6570\u636e\u7ed3\u6784\u901a\u5e38\u662f struct cJSON&#xff0c;\u901a\u8fc7\u4e00\u7cfb\u5217\u51fd\u6570&#xff08;\u5982 cJSON_Parse, cJSON_GetObjectItem, cJSON_CreateObject, cJSON_Print \u7b49&#xff09;\u8fdb\u884c\u64cd\u4f5c\u3002<\/li>\n<li>\u94fe\u5f0f\u5b58\u50a8: \u5185\u90e8\u4f7f\u7528\u94fe\u8868\u6765\u7ba1\u7406 JSON \u5bf9\u8c61\u4e2d\u7684\u6210\u5458\u548c\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u3002<\/li>\n<li>\u5185\u5b58\u7ba1\u7406: \u5e93\u8d1f\u8d23\u5728\u89e3\u6790\u65f6\u5206\u914d\u5185\u5b58&#xff08;\u901a\u5e38\u5728\u5806\u4e0a&#xff09;&#xff0c;\u5e76\u63d0\u4f9b\u4e86\u91ca\u653e\u6574\u4e2a\u89e3\u6790\u6811\u5185\u5b58\u7684\u51fd\u6570&#xff08;cJSON_Delete&#xff09;\u3002\u4f7f\u7528\u8005\u9700\u8981\u8d1f\u8d23\u7ba1\u7406\u8f93\u5165\u5b57\u7b26\u4e32\u548c\u8f93\u51fa\u5b57\u7b26\u4e32\u7684\u5185\u5b58\u3002<\/li>\n<\/ul>\n<h3>4\u3001 \u6570\u636e\u7ed3\u6784<\/h3>\n<p>cJSON \u5e93\u7684\u6838\u5fc3\u662f cJSON \u7ed3\u6784\u4f53&#xff08;\u901a\u5e38\u5728 cJSON.h \u4e2d\u5b9a\u4e49&#xff09;&#xff0c;\u5b83\u7528\u6765\u8868\u793a JSON \u6570\u636e\u4e2d\u7684\u5404\u79cd\u7c7b\u578b&#xff08;\u5bf9\u8c61\u3001\u6570\u7ec4\u3001\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u3001\u5e03\u5c14\u503c\u3001null&#xff09;\u3002\u8fd9\u4e2a\u7ed3\u6784\u4f53\u901a\u5e38\u5305\u542b\u4ee5\u4e0b\u6210\u5458&#xff08;\u5177\u4f53\u5b9e\u73b0\u53ef\u80fd\u7565\u6709\u5dee\u5f02&#xff09;&#xff1a;<\/p>\n<ul>\n<li>type: \u8868\u793a\u8be5\u8282\u70b9\u7684 JSON \u6570\u636e\u7c7b\u578b&#xff08;\u5982 cJSON_Object, cJSON_Array, cJSON_String, cJSON_Number \u7b49&#xff09;\u3002<\/li>\n<li>valuestring: \u5f53\u7c7b\u578b\u662f\u5b57\u7b26\u4e32\u65f6&#xff0c;\u5b58\u50a8\u5b57\u7b26\u4e32\u503c&#xff08;\u5bf9\u4e8e\u6570\u5b57\u7c7b\u578b&#xff0c;\u53ef\u80fd\u5b58\u50a8\u5176\u5b57\u7b26\u4e32\u8868\u793a&#xff09;\u3002<\/li>\n<li>valueint, valuedouble: \u5b58\u50a8\u6574\u6570\u503c\u6216\u6d6e\u70b9\u6570\u503c&#xff08;\u53d6\u51b3\u4e8e\u89e3\u6790\u65b9\u5f0f\u548c\u914d\u7f6e&#xff09;\u3002<\/li>\n<li>child: \u5bf9\u4e8e\u5bf9\u8c61\u6216\u6570\u7ec4\u7c7b\u578b&#xff0c;\u6307\u5411\u5176\u7b2c\u4e00\u4e2a\u5b50\u8282\u70b9&#xff08;\u5bf9\u8c61\u6210\u5458\u6216\u6570\u7ec4\u5143\u7d20&#xff09;\u3002<\/li>\n<li>next, prev: \u7528\u4e8e\u5728\u94fe\u8868&#xff08;\u5bf9\u8c61\u6210\u5458\u94fe\u8868\u6216\u6570\u7ec4\u5143\u7d20\u94fe\u8868&#xff09;\u4e2d\u8fde\u63a5\u5144\u5f1f\u8282\u70b9\u3002<\/li>\n<li>string: \u5bf9\u4e8e\u5bf9\u8c61\u4e2d\u7684\u6210\u5458&#xff0c;\u5b58\u50a8\u8be5\u6210\u5458\u7684\u952e\u540d\u3002<\/li>\n<\/ul>\n<h3>5\u3001\u57fa\u672c\u4f7f\u7528\u6d41\u7a0b<\/h3>\n<li>\u89e3\u6790 JSON:<span class=\"token keyword\">const<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>json_string <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;{\\\\&#034;name\\\\&#034;:\\\\&#034;Alice\\\\&#034;,\\\\&#034;age\\\\&#034;:30}&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\ncJSON <span class=\"token operator\">*<\/span>root <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">cJSON_Parse<\/span><span class=\"token punctuation\">(<\/span>json_string<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>root <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>error_ptr <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">cJSON_GetErrorPtr<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>error_ptr <span class=\"token operator\">!&#061;<\/span> <span class=\"token constant\">NULL<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">fprintf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">stderr<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;Error before: %s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> error_ptr<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u5904\u7406\u89e3\u6790\u9519\u8bef<\/span><br \/>\n<span class=\"token punctuation\">}<\/span>\n <\/li>\n<li>\u8bbf\u95ee\u6570\u636e:cJSON <span class=\"token operator\">*<\/span>name <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">cJSON_GetObjectItemCaseSensitive<\/span><span class=\"token punctuation\">(<\/span>root<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;name&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">cJSON_IsString<\/span><span class=\"token punctuation\">(<\/span>name<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Name: %s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> name<span class=\"token operator\">-&gt;<\/span>valuestring<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\ncJSON <span class=\"token operator\">*<\/span>age <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">cJSON_GetObjectItemCaseSensitive<\/span><span class=\"token punctuation\">(<\/span>root<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;age&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">cJSON_IsNumber<\/span><span class=\"token punctuation\">(<\/span>age<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Age: %d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> age<span class=\"token operator\">-&gt;<\/span>valueint<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u6216\u8005 age-&gt;valuedouble<\/span><br \/>\n<span class=\"token punctuation\">}<\/span>\n <\/li>\n<li>\u751f\u6210 JSON:cJSON <span class=\"token operator\">*<\/span>root <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">cJSON_CreateObject<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">cJSON_AddStringToObject<\/span><span class=\"token punctuation\">(<\/span>root<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;name&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;Bob&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">cJSON_AddNumberToObject<\/span><span class=\"token punctuation\">(<\/span>root<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;age&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">25<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>json_output <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">cJSON_Print<\/span><span class=\"token punctuation\">(<\/span>root<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u683c\u5f0f\u5316\u8f93\u51fa<\/span><br \/>\n<span class=\"token comment\">\/\/ char *json_output &#061; cJSON_PrintUnformatted(root); \/\/ \u7d27\u51d1\u8f93\u51fa<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> json_output<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/\/ \u4f7f\u7528\u5b8c\u540e\u91ca\u653e\u8f93\u51fa\u5b57\u7b26\u4e32<\/span><br \/>\n<span class=\"token function\">free<\/span><span class=\"token punctuation\">(<\/span>json_output<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n <\/li>\n<li>\u91ca\u653e\u8d44\u6e90:<span class=\"token function\">cJSON_Delete<\/span><span class=\"token punctuation\">(<\/span>root<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u91ca\u653e\u6574\u4e2a\u89e3\u6790\u6811\u5360\u7528\u7684\u5185\u5b58<\/span>\n <\/li>\n<h2>\u4e09\u3001\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u4e92\u8f6c<\/h2>\n<h3>1\u3001\u4e0b\u8f7d\u6e90\u7801<\/h3>\n<p>\u70b9\u51fb\u4e0b\u8f7d<\/p>\n<h3>2\u3001\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p><span class=\"token comment\">\/** \u9879\u76ee\u7ed3\u6784\u4f53 *\/<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">project<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> id<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>name<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/** \u4ed3\u5e93\u7ed3\u6784\u4f53 *\/<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">hub<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> id<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>user<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">project<\/span> <span class=\"token operator\">*<\/span>cson<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/** \u9879\u76ee\u7ed3\u6784\u4f53\u6570\u636e\u6a21\u578b *\/<\/span><br \/>\nCsonModel projectModel<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">CSON_MODEL_OBJ<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">project<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token function\">CSON_MODEL_INT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">project<\/span><span class=\"token punctuation\">,<\/span> id<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token function\">CSON_MODEL_STRING<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">project<\/span><span class=\"token punctuation\">,<\/span> name<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/** \u4ed3\u5e93\u7ed3\u6784\u4f53\u6570\u636e\u6a21\u578b *\/<\/span><br \/>\nCsonModel hubModel<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">CSON_MODEL_OBJ<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">hub<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token function\">CSON_MODEL_INT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">hub<\/span><span class=\"token punctuation\">,<\/span> id<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token function\">CSON_MODEL_STRING<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">hub<\/span><span class=\"token punctuation\">,<\/span> user<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token function\">CSON_MODEL_STRUCT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">hub<\/span><span class=\"token punctuation\">,<\/span> cson<span class=\"token punctuation\">,<\/span> projectModel<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>projectModel<span class=\"token punctuation\">)<\/span><span class=\"token operator\">\/<\/span><span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>CsonModel<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">csonDemo<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>jsonDemo <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;{\\\\&#034;id\\\\&#034;: 1, \\\\&#034;user\\\\&#034;: \\\\&#034;Letter\\\\&#034;, \\\\&#034;cson\\\\&#034;: {\\\\&#034;id\\\\&#034;: 2, \\\\&#034;name\\\\&#034;: \\\\&#034;cson\\\\&#034;}}&#034;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/** \u89e3\u6790json *\/<\/span><br \/>\n    <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">hub<\/span> <span class=\"token operator\">*<\/span>pHub <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">csonDecode<\/span><span class=\"token punctuation\">(<\/span>jsonDemo<span class=\"token punctuation\">,<\/span> hubModel<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>hubModel<span class=\"token punctuation\">)<\/span><span class=\"token operator\">\/<\/span><span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>CsonModel<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;hub: id: %d, user: %s, project id: %d, project name: %s\\\\r\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        pHub<span class=\"token operator\">-&gt;<\/span>id<span class=\"token punctuation\">,<\/span> pHub<span class=\"token operator\">-&gt;<\/span>user<span class=\"token punctuation\">,<\/span> pHub<span class=\"token operator\">-&gt;<\/span>cson<span class=\"token operator\">-&gt;<\/span>id<span class=\"token punctuation\">,<\/span> pHub<span class=\"token operator\">-&gt;<\/span>cson<span class=\"token operator\">-&gt;<\/span>name<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/** \u5e8f\u5217\u5316\u5bf9\u8c61 *\/<\/span><br \/>\n    <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>formatJson <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">csonEncode<\/span><span class=\"token punctuation\">(<\/span>pHub<span class=\"token punctuation\">,<\/span> hubModel<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>hubModel<span class=\"token punctuation\">)<\/span><span class=\"token operator\">\/<\/span><span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>CsonModel<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">512<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;format json: %s\\\\r\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> formatJson<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/** \u91ca\u653e\u7ed3\u6784\u4f53\u5bf9\u8c61 *\/<\/span><br \/>\n    <span class=\"token function\">csonFree<\/span><span class=\"token punctuation\">(<\/span>pHub<span class=\"token punctuation\">,<\/span> hubModel<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>hubModel<span class=\"token punctuation\">)<\/span><span class=\"token operator\">\/<\/span><span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>CsonModel<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/** \u91ca\u653e\u5e8f\u5217\u5316\u751f\u6210\u7684json\u5b57\u7b26\u4e32 *\/<\/span><br \/>\n    <span class=\"token function\">csonFreeJson<\/span><span class=\"token punctuation\">(<\/span>formatJson<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd0\u884c\u7ed3\u679c<\/p>\n<p>hub<span class=\"token operator\">:<\/span> id<span class=\"token operator\">:<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> user<span class=\"token operator\">:<\/span> Letter<span class=\"token punctuation\">,<\/span> project id<span class=\"token operator\">:<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> project name<span class=\"token operator\">:<\/span> cson<br \/>\nformat json<span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token string\">&#034;id&#034;<\/span><span class=\"token operator\">:<\/span>   <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        <span class=\"token string\">&#034;user&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;Letter&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        <span class=\"token string\">&#034;cson&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n                <span class=\"token string\">&#034;id&#034;<\/span><span class=\"token operator\">:<\/span>   <span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span><br \/>\n                <span class=\"token string\">&#034;name&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;cson&#034;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260113232548-6966d47c275cb.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>C\/C \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316\u4e00\u3001\u4ec0\u4e48\u662fjson1\u3001\u6838\u5fc3\u7279\u60272\u3001\u5e94\u7528\u573a\u666f3\u3001\u793a\u4f8b\u89e3\u67904\u3001\u6ce8\u610f\u4e8b\u9879\u4e8c\u3001cJSON\u5e93\u4ecb\u7ecd1\u3001 \u6982\u8ff02\u3001 \u6838\u5fc3\u529f\u80fd3\u3001\u4e3b\u8981\u7279\u70b94\u3001 \u6570\u636e\u7ed3\u67845\u3001\u57fa\u672c\u4f7f\u7528\u6d41\u7a0b\u4e09\u3001\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u4e92\u8f6c1\u3001\u4e0b\u8f7d\u6e90\u78012\u3001\u4f7f\u7528\u65b9\u6cd5\u4e00\u3001\u4ec0\u4e48\u662fjson<br \/>\nJSON&#xff08;JavaScript Object Notation&#xff09;\u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f&#xff0c;\u5e38\u7528\u4e8e\u7f51\u7edc\u6570\u636e\u4f20\u8f93\u548c\u914d\u7f6e\u6587\u4ef6\u3002\u5b83\u91c7\u7528\u4eba\u7c7b\u53ef\u8bfb\u7684\u6587\u672c\u683c\u5f0f&amp;#<\/p>\n","protected":false},"author":2,"featured_media":59583,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,174,93],"topic":[],"class_list":{"0":"post-59585","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-server","8":"tag-c","10":"tag-json"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C\/C++ \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/59585.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C\/C++ \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"C\/C \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316\u4e00\u3001\u4ec0\u4e48\u662fjson1\u3001\u6838\u5fc3\u7279\u60272\u3001\u5e94\u7528\u573a\u666f3\u3001\u793a\u4f8b\u89e3\u67904\u3001\u6ce8\u610f\u4e8b\u9879\u4e8c\u3001cJSON\u5e93\u4ecb\u7ecd1\u3001 \u6982\u8ff02\u3001 \u6838\u5fc3\u529f\u80fd3\u3001\u4e3b\u8981\u7279\u70b94\u3001 \u6570\u636e\u7ed3\u67845\u3001\u57fa\u672c\u4f7f\u7528\u6d41\u7a0b\u4e09\u3001\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u4e92\u8f6c1\u3001\u4e0b\u8f7d\u6e90\u78012\u3001\u4f7f\u7528\u65b9\u6cd5\u4e00\u3001\u4ec0\u4e48\u662fjson JSON&#xff08;JavaScript Object Notation&#xff09;\u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f&#xff0c;\u5e38\u7528\u4e8e\u7f51\u7edc\u6570\u636e\u4f20\u8f93\u548c\u914d\u7f6e\u6587\u4ef6\u3002\u5b83\u91c7\u7528\u4eba\u7c7b\u53ef\u8bfb\u7684\u6587\u672c\u683c\u5f0f&amp;#\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/59585.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-13T23:25:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260113232547-6966d47babd8e.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/59585.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/59585.html\",\"name\":\"C\/C++ \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-13T23:25:49+00:00\",\"dateModified\":\"2026-01-13T23:25:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/59585.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/59585.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/59585.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C\/C++ \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C\/C++ \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/59585.html","og_locale":"zh_CN","og_type":"article","og_title":"C\/C++ \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"C\/C \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316\u4e00\u3001\u4ec0\u4e48\u662fjson1\u3001\u6838\u5fc3\u7279\u60272\u3001\u5e94\u7528\u573a\u666f3\u3001\u793a\u4f8b\u89e3\u67904\u3001\u6ce8\u610f\u4e8b\u9879\u4e8c\u3001cJSON\u5e93\u4ecb\u7ecd1\u3001 \u6982\u8ff02\u3001 \u6838\u5fc3\u529f\u80fd3\u3001\u4e3b\u8981\u7279\u70b94\u3001 \u6570\u636e\u7ed3\u67845\u3001\u57fa\u672c\u4f7f\u7528\u6d41\u7a0b\u4e09\u3001\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u4e92\u8f6c1\u3001\u4e0b\u8f7d\u6e90\u78012\u3001\u4f7f\u7528\u65b9\u6cd5\u4e00\u3001\u4ec0\u4e48\u662fjson JSON&#xff08;JavaScript Object Notation&#xff09;\u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f&#xff0c;\u5e38\u7528\u4e8e\u7f51\u7edc\u6570\u636e\u4f20\u8f93\u548c\u914d\u7f6e\u6587\u4ef6\u3002\u5b83\u91c7\u7528\u4eba\u7c7b\u53ef\u8bfb\u7684\u6587\u672c\u683c\u5f0f&amp;#","og_url":"https:\/\/www.wsisp.com\/helps\/59585.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-13T23:25:49+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260113232547-6966d47babd8e.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/59585.html","url":"https:\/\/www.wsisp.com\/helps\/59585.html","name":"C\/C++ \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-13T23:25:49+00:00","dateModified":"2026-01-13T23:25:49+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/59585.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/59585.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/59585.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C\/C++ \u4f7f\u7528cJSON\u5e93\u5b9e\u73b0\u7ed3\u6784\u4f53\u548cjson\u5b57\u7b26\u4e32\u76f8\u4e92\u5e8f\u5217\u5316"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/59585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=59585"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/59585\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/59583"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=59585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=59585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=59585"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=59585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}