"use strict";(self.webpackChunkfurion=self.webpackChunkfurion||[]).push([[3009],{8069:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>x,frontMatter:()=>l,metadata:()=>a,toc:()=>t});var s=r(5893),i=r(1151),c=r(510);const l={id:"clayobj",title:"29. \u7c98\u571f\u5bf9\u8c61",sidebar_label:"29. \u7c98\u571f\u5bf9\u8c61"},d=void 0,a={id:"clayobj",title:"29. \u7c98\u571f\u5bf9\u8c61",description:"\ud83d\udcdd \u6a21\u5757\u66f4\u65b0\u65e5\u5fd7",source:"@site/docs/clayobj.mdx",sourceDirName:".",slug:"/clayobj",permalink:"/docs/clayobj",draft:!1,unlisted:!1,editUrl:"https://gitee.com/dotnetchina/Furion/tree/v4/handbook/docs/clayobj.mdx",tags:[],version:"current",lastUpdatedBy:"\u767e\u5c0f\u50e7",lastUpdatedAt:1696858025,formattedLastUpdatedAt:"Oct 9, 2023",frontMatter:{id:"clayobj",title:"29. \u7c98\u571f\u5bf9\u8c61",sidebar_label:"29. \u7c98\u571f\u5bf9\u8c61"},sidebar:"docs",previous:{title:"28. \u6a21\u5757\u5316\u5f00\u53d1",permalink:"/docs/module-dev"},next:{title:"30. \u8131\u654f\u5904\u7406",permalink:"/docs/sensitive-detection"}},o={},t=[{value:"29.1 \u5173\u4e8e\u7c98\u571f\u5bf9\u8c61",id:"291-\u5173\u4e8e\u7c98\u571f\u5bf9\u8c61",level:2},{value:"29.1.1 \u4f7f\u7528\u573a\u666f",id:"2911-\u4f7f\u7528\u573a\u666f",level:3},{value:"29.1.2 \u5173\u4e8e\u6027\u80fd",id:"2912-\u5173\u4e8e\u6027\u80fd",level:3},{value:"29.2 Clay
\u5bf9\u8c61",id:"292-clay-\u5bf9\u8c61",level:2},{value:"29.3 \u5982\u4f55\u4f7f\u7528",id:"293-\u5982\u4f55\u4f7f\u7528",level:2},{value:"29.3.1 \u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61",id:"2931-\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61",level:3},{value:"29.3.2 \u8bfb\u53d6/\u83b7\u53d6\u5c5e\u6027",id:"2932-\u8bfb\u53d6\u83b7\u53d6\u5c5e\u6027",level:3},{value:"29.3.3 \u65b0\u589e\u5c5e\u6027",id:"2933-\u65b0\u589e\u5c5e\u6027",level:3},{value:"29.3.4 \u66f4\u65b0\u5c5e\u6027\u503c",id:"2934-\u66f4\u65b0\u5c5e\u6027\u503c",level:3},{value:"29.3.5 \u5220\u9664\u5c5e\u6027",id:"2935-\u5220\u9664\u5c5e\u6027",level:3},{value:"29.3.6 \u5224\u65ad\u952e/\u7d22\u5f15\u662f\u5426\u5b58\u5728",id:"2936-\u5224\u65ad\u952e\u7d22\u5f15\u662f\u5426\u5b58\u5728",level:3},{value:"29.3.7 \u904d\u5386\u5bf9\u8c61",id:"2937-\u904d\u5386\u5bf9\u8c61",level:3},{value:"29.3.8 \u8f6c\u6362\u6210\u5177\u4f53\u5bf9\u8c61",id:"2938-\u8f6c\u6362\u6210\u5177\u4f53\u5bf9\u8c61",level:3},{value:"29.3.9 \u56fa\u5316\u7c98\u571f",id:"2939-\u56fa\u5316\u7c98\u571f",level:3},{value:"29.3.10 \u8f93\u51fa JSON
",id:"29310-\u8f93\u51fa-json",level:3},{value:"29.3.11 \u8f93\u51fa XML
\u5bf9\u8c61",id:"29311-\u8f93\u51fa-xml-\u5bf9\u8c61",level:3},{value:"29.3.12 \u5173\u952e\u5b57\u5904\u7406",id:"29312-\u5173\u952e\u5b57\u5904\u7406",level:3},{value:"29.3.13 \u8f6c\u6362\u6210\u5b57\u5178\u7c7b\u578b",id:"29313-\u8f6c\u6362\u6210\u5b57\u5178\u7c7b\u578b",level:3},{value:"29.3.14 \u83b7\u53d6\u4e0d\u5b58\u5728 Key
\u5904\u7406",id:"29314-\u83b7\u53d6\u4e0d\u5b58\u5728-key-\u5904\u7406",level:3},{value:"29.3.15 \u8f6c\u6362\u4e3a\u7279\u5b9a\u96c6\u5408",id:"29315-\u8f6c\u6362\u4e3a\u7279\u5b9a\u96c6\u5408",level:3},{value:"29.4 \u5e8f\u5217\u5316\u652f\u6301",id:"294-\u5e8f\u5217\u5316\u652f\u6301",level:2},{value:"29.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"295-\u53cd\u9988\u4e0e\u5efa\u8bae",level:2}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",li:"li",mdxAdmonitionTitle:"mdxAdmonitionTitle",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.a)(),...e.components},{Details:r}=n;return r||function(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(r,{children:[(0,s.jsx)("summary",{children:"\ud83d\udcdd \u6a21\u5757\u66f4\u65b0\u65e5\u5fd7"}),(0,s.jsx)("div",{children:(0,s.jsxs)("div",{children:[(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u65b0\u7279\u6027"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u65b0\u589e"})," \u7c98\u571f\u5bf9\u8c61 ",(0,s.jsx)(n.code,{children:".ConvertTo"})," \u652f\u6301\u81ea\u5b9a\u4e49\u503c\u63d0\u4f9b\u5668 ",(0,s.jsx)("sup",{children:"4.8.8.40"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.08.03"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/70d58888b3cec88c5c2a8458654dca1881e2a88b",children:"70d5888"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u65b0\u589e"})," \u7c98\u571f\u5bf9\u8c61\u652f\u6301\u7ed3\u6784 ",(0,s.jsx)(n.code,{children:"struct"})," \u5bf9\u8c61\u7c7b\u578b ",(0,s.jsx)("sup",{children:"4.8.8.7"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.04.30"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/a0fa3aa7ae536e948740401b510d99cf45e251dc",children:"a0fa3aa"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u65b0\u589e"})," \u7c98\u571f\u5bf9\u8c61\u53ef\u53cd\u5c04\u8f6c\u6362\u6210\u7279\u5b9a ",(0,s.jsx)(n.code,{children:"IEnumerable"})," \u7c7b\u578b\uff1a",(0,s.jsx)(n.code,{children:"clay.ConverTo()"})," ",(0,s.jsx)("sup",{children:"4.8.8"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.04.13"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/5d54a6579be3d710649bb199dd985f60acaf9787",children:"5d54a65"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u65b0\u589e"})," ",(0,s.jsxs)(n.strong,{children:["\u7c98\u571f\u5bf9\u8c61\u53ef\u914d\u7f6e\u8bbf\u95ee\u4e0d\u5b58\u5728 ",(0,s.jsx)(n.code,{children:"Key"})," \u65f6\u662f\u629b\u5f02\u5e38\u8fd8\u662f\u8fd4\u56de ",(0,s.jsx)(n.code,{children:"null"})]})," ",(0,s.jsx)("sup",{children:"4.8.7.40"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.04.10"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/e994d53b64a825461673f48960df1716be44f192",children:"e994d53"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u65b0\u589e"})," ",(0,s.jsxs)(n.strong,{children:["\u7c98\u571f\u5bf9\u8c61\u53ef\u8f6c\u6362\u6210 ",(0,s.jsx)(n.code,{children:"IEnumerable"})," \u5bf9\u8c61\u5e76\u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"Lambda/Linq"})," \u64cd\u4f5c"]})," ",(0,s.jsx)("sup",{children:"4.8.7.19"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.03.22"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/2b14ed9da03699619b1fade6e053f65b77a5b0fe",children:"2b14ed9"})]}),"\n"]}),"\n"]}),"\n"]}),(0,s.jsxs)(r,{style:{marginLeft:50},children:[(0,s.jsx)("summary",{children:"\u67e5\u770b\u53d8\u5316"}),(0,s.jsx)("div",{children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {3-4,6-12}",children:'dynamic clay = Clay.Parse("{\\"Foo\\":\\"json\\",\\"Bar\\":100,\\"Nest\\":{\\"Foobar\\":true},\\"Arr\\":[\\"NOR\\",\\"XOR\\"]}");\r\n\r\n// \u5c06 clay.Arr \u8f6c\u6362\u6210 IEnumerable\r\nIEnumerable query = clay.Arr.AsEnumerator();\r\n\r\n// \u5b9e\u73b0 Lambda/Linq \u64cd\u4f5c\r\nvar result = query.Where(u => u.StartsWith("N"))\r\n .Select(u => new\r\n {\r\n Name = u\r\n })\r\n .ToList();\n'})})})]}),(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u65b0\u589e"})," \u7c98\u571f\u5bf9\u8c61\u652f\u6301\u4efb\u4f55\u5b57\u7b26\u4f5c\u4e3a ",(0,s.jsx)(n.code,{children:"JSON/XML"})," \u952e ",(0,s.jsx)("sup",{children:"4.8.6.9"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.02.19"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/f99aee8dafddf3cfd148922166abd3998e8eb087",children:"f99aee8"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/4961e01486f604db12a8d8d71f9bd563ed7d7d48#note_16329657",children:"#note_16329657"})]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u95ee\u9898\u4fee\u590d"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u4fee\u590d"})," \u7c98\u571f\u5bf9\u8c61\u4e0d\u652f\u6301\u679a\u4e3e\u7c7b\u578b\u95ee\u9898 ",(0,s.jsx)("sup",{children:"4.8.8.41"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.08.25"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I7VDDL",children:"#I7VDDL"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u4fee\u590d"})," ",(0,s.jsx)(n.code,{children:"ExpandoObject.ToDictionary()"})," \u8f6c\u6362\u5f02\u5e38 ",(0,s.jsx)("sup",{children:"4.8.8.25"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.06.14"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I7BY0P",children:"#I7BY0P"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u4fee\u590d"})," \u7c98\u571f\u5bf9\u8c61\u8f6c\u6362\u4e3a ",(0,s.jsx)(n.code,{children:"Dictionary"})," \u7c7b\u578b\u5f02\u5e38 ",(0,s.jsx)("sup",{children:"4.8.7.41"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.04.11"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/f96baebbb06b53fc481ea7925cbbfbcb191f9c10",children:"f96baeb"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u4fee\u590d"})," \u7c98\u571f\u5bf9\u8c61\u4e0d\u652f\u6301\u8fd0\u884c\u65f6\u52a8\u6001\u8bbe\u7f6e\u643a\u5e26\u7279\u6b8a\u5b57\u7b26\u7684 ",(0,s.jsx)(n.code,{children:"Key"})," \u952e ",(0,s.jsx)("sup",{children:"4.8.7.39"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.04.10"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/6572515abbd93c4572cc513da4dd5aa497d144d2",children:"6572515"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u4fee\u590d"})," \u7c98\u571f\u5bf9\u8c61\u904d\u5386\u5bf9\u8c61\u952e\u503c\u5bf9\u56e0 ",(0,s.jsx)(n.code,{children:"4.8.7.19"})," \u7248\u672c\u66f4\u65b0\u5bfc\u81f4\u5f02\u5e38 ",(0,s.jsx)("sup",{children:"4.8.7.25"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.03.28"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/issues/I6R4ZU",children:"#I6R4ZU"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u4fee\u590d"})," \u7c98\u571f\u5bf9\u8c61\u4e0d\u652f\u6301 ",(0,s.jsx)(n.code,{children:"\u6570\u5b57"})," \u4f5c\u4e3a ",(0,s.jsx)(n.code,{children:"JSON/XML"})," \u952e\u95ee\u9898 ",(0,s.jsx)("sup",{children:"4.8.6.9"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.02.19"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/4961e01486f604db12a8d8d71f9bd563ed7d7d48#note_16329657",children:"#note_16329657"})]}),"\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u4fee\u590d"})," \u7c98\u571f\u5bf9\u8c61\u4e0d\u652f\u6301 ",(0,s.jsx)(n.code,{children:"\u4e2d\u6587"})," \u4f5c\u4e3a ",(0,s.jsx)(n.code,{children:"JSON/XML"})," \u952e\u95ee\u9898 ",(0,s.jsx)("sup",{children:"4.8.6.6"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.02.18"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/4961e01486f604db12a8d8d71f9bd563ed7d7d48",children:"4961e01"})]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u5176\u4ed6\u66f4\u6539"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\xa0",(0,s.jsx)(c.Z,{children:"\u8c03\u6574"})," \u7c98\u571f\u5bf9\u8c61 ",(0,s.jsx)(n.code,{children:"number"})," \u7c7b\u578b\u5904\u7406\uff0c\u82e5\u542b ",(0,s.jsx)(n.code,{children:"."})," \u8f6c ",(0,s.jsx)(n.code,{children:"double"})," \u7c7b\u578b\uff0c\u5426\u5219\u8f6c ",(0,s.jsx)(n.code,{children:"long"})," \u7c7b\u578b ",(0,s.jsx)("sup",{children:"4.8.7.24"})," ",(0,s.jsx)("sup",{children:"\u23f1\ufe0f2023.03.28"})," ",(0,s.jsx)(n.a,{href:"https://gitee.com/dotnetchina/Furion/commit/e82e883d54282b749390ae5e93df8c3e7acaa97e",children:"e82e883"})]}),"\n"]}),"\n"]}),"\n"]})]})})]}),"\n",(0,s.jsx)(n.admonition,{title:"\u7248\u672c\u8bf4\u660e",type:"important",children:(0,s.jsxs)(n.p,{children:["\u4ee5\u4e0b\u5185\u5bb9\u4ec5\u9650 ",(0,s.jsx)(n.code,{children:"Furion 2.1.12 +"})," \u7248\u672c\u4f7f\u7528\u3002"]})}),"\n",(0,s.jsx)(n.h2,{id:"291-\u5173\u4e8e\u7c98\u571f\u5bf9\u8c61",children:"29.1 \u5173\u4e8e\u7c98\u571f\u5bf9\u8c61"}),"\n",(0,s.jsxs)(n.p,{children:["\u7c98\u571f\u5bf9\u8c61\u662f ",(0,s.jsx)(n.code,{children:"Furion"})," \u6846\u67b6\u63a8\u51fa\u7684\u4e00\u79cd\u52a8\u6001\u7c7b\u578b\uff0c\u53ef\u4ee5\u6a21\u62df\u5f31\uff08\u52a8\u6001\uff09\u8bed\u8a00\u64cd\u4f5c\u7279\u6027\uff0c\u4f7f C# \u5bf9\u8c61\u5b9e\u73b0\u7c7b\u4f3c ",(0,s.jsx)(n.code,{children:"JavaScript"})," \u4e00\u6837\u64cd\u4f5c\u5bf9\u8c61\u3002\u53ea\u9700\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"Clay"})," \u7c7b\u521d\u59cb\u5316\u5373\u53ef\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u4e3a\u4ec0\u4e48\u8d77\u540d\u4e3a \u201c\u7c98\u571f\u201d \u5462\uff1f\u56e0\u4e3a\u8fd9\u4e2a\u5bf9\u8c61\u53ef\u4ee5\u81ea\u7531\u7684\u6dfb\u52a0\u5c5e\u6027\uff0c\u79fb\u9664\u5c5e\u6027\uff0c\u53c8\u53ef\u4ee5\u56fa\u5316\u6210\u4efb\u4f55\u5bf9\u8c61\uff0c\u5177\u6709\u53ef\u62d3\u5c55\u3001\u53ef\u5851\u9020\u7684\u7279\u70b9\u3002"})}),"\n",(0,s.jsx)(n.h3,{id:"2911-\u4f7f\u7528\u573a\u666f",children:"29.1.1 \u4f7f\u7528\u573a\u666f"}),"\n",(0,s.jsxs)(n.p,{children:["\u7c98\u571f\u5bf9\u8c61\u5e38\u7528\u4e8e\u9700\u8981\u52a8\u6001\u6784\u5efa\u5bf9\u8c61\u7684\u5730\u65b9\uff0c\u5982 ",(0,s.jsx)(n.code,{children:"CMS"})," \u7cfb\u7edf\u7684 ",(0,s.jsx)(n.code,{children:"ViewModel"}),"\uff0c\u6216\u8005\u8fd0\u884c\u65f6\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61\uff0c\u6216\u8005\u8bf7\u6c42\u7b2c\u4e09\u65b9 ",(0,s.jsx)(n.code,{children:"API"})," \u60c5\u51b5\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"2912-\u5173\u4e8e\u6027\u80fd",children:"29.1.2 \u5173\u4e8e\u6027\u80fd"}),"\n",(0,s.jsx)(n.p,{children:"\u7c98\u571f\u6027\u80fd\u5b9e\u9645\u4e0a\u5e76\u4e0d\u9ad8\u6548\uff0c\u4f46\u662f\u6027\u80fd\u4e5f\u5e76\u4e0d\u4f4e\u4e0b\uff0c\u53ea\u4e0d\u8fc7\u7565\u8f93\u4e8e\u5f3a\u7c7b\u578b\u8c03\u7528\u3002\u4ec0\u4e48\u65f6\u5019\u4f7f\u7528\u53ef\u4ee5\u770b\u4ee5\u4e0a\u7684\u3010\u4f7f\u7528\u573a\u666f\u3011\u3002"}),"\n",(0,s.jsxs)(n.h2,{id:"292-clay-\u5bf9\u8c61",children:["29.2 ",(0,s.jsx)(n.code,{children:"Clay"})," \u5bf9\u8c61"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Clay"})," \u5bf9\u8c61\u662f\u7ee7\u627f\u81ea ",(0,s.jsx)(n.code,{children:"DynamicObject"})," \u7684\u4e00\u4e2a\u7279\u6b8a\u5bf9\u8c61\uff0c\u63d0\u4f9b\u4e86\u50cf\u5f31\uff08\u52a8\u6001\uff09\u8bed\u8a00\u4e00\u6837\u64cd\u4f5c\u5bf9\u8c61\u7684\u65b9\u6cd5\u53ca\u7d22\u5f15\u83b7\u53d6\u65b9\u5f0f\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"293-\u5982\u4f55\u4f7f\u7528",children:"29.3 \u5982\u4f55\u4f7f\u7528"}),"\n",(0,s.jsx)(n.h3,{id:"2931-\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61",children:"29.3.1 \u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {2,5,8}",children:'// \u521b\u5efa\u4e00\u4e2a\u7a7a\u7684\u7c98\u571f\u5bf9\u8c61\r\ndynamic clay = new Clay();\r\n\r\n// \u4ece\u73b0\u6709\u7684\u5bf9\u8c61\u521b\u5efa\r\ndynamic clay2 = Clay.Object(new {});\r\n\r\n// \u4ece json \u5b57\u7b26\u4e32\u521b\u5efa\uff0c\u53ef\u7528\u4e8e\u7b2c\u4e09\u65b9 API \u5bf9\u63a5\uff0c\u975e\u5e38\u6709\u7528\r\ndynamic clay3 = Clay.Parse(@"{""foo"":""json"", ""bar"":100, ""nest"":{ ""foobar"":true } }");\n'})}),"\n",(0,s.jsx)(n.h3,{id:"2932-\u8bfb\u53d6\u83b7\u53d6\u5c5e\u6027",children:"29.3.2 \u8bfb\u53d6/\u83b7\u53d6\u5c5e\u6027"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,11-14}",children:'dynamic clay = Clay.Object(new\r\n{\r\n Foo = "json",\r\n Bar = 100,\r\n Nest = new\r\n {\r\n Foobar = true\r\n }\r\n});\r\n\r\nvar r1 = clay.Foo; // "json" - string\u7c7b\u578b\r\nvar r2 = clay.Bar; // 100 - double\u7c7b\u578b\r\nvar r3 = clay.Nest.Foobar; // true - bool\u7c7b\u578b\r\nvar r4 = clay["Nest"]["Foobar"]; // \u8fd8\u53ef\u4ee5\u548c JavaScript \u4e00\u6837\u901a\u8fc7\u7d22\u5f15\u5668\u83b7\u53d6\n'})}),"\n",(0,s.jsx)(n.h3,{id:"2933-\u65b0\u589e\u5c5e\u6027",children:"29.3.3 \u65b0\u589e\u5c5e\u6027"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,12-14}",children:'dynamic clay = Clay.Object(new\r\n{\r\n Foo = "json",\r\n Bar = 100,\r\n Nest = new\r\n {\r\n Foobar = true\r\n }\r\n});\r\n\r\n// \u65b0\u589e\r\nclay.Arr = new string[] { "NOR", "XOR" }; // \u6dfb\u52a0\u4e00\u4e2a\u6570\u7ec4\r\nclay.Obj1 = new City { }; // \u65b0\u589e\u4e00\u4e2a\u5b9e\u4f8b\u5bf9\u8c61\r\nclay.Obj2 = new { Foo = "abc", Bar = 100 }; // \u65b0\u589e\u4e00\u4e2a\u533f\u540d\u7c7b\n'})}),"\n",(0,s.jsx)(n.h3,{id:"2934-\u66f4\u65b0\u5c5e\u6027\u503c",children:"29.3.4 \u66f4\u65b0\u5c5e\u6027\u503c"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,12-14}",children:'dynamic clay = Clay.Object(new\r\n{\r\n Foo = "json",\r\n Bar = 100,\r\n Nest = new\r\n {\r\n Foobar = true\r\n }\r\n});\r\n\r\n// \u66f4\u65b0\r\nclay.Foo = "Furion";\r\nclay["Nest"].Foobar = false;\r\nclay.Nest["Foobar"] = true;\n'})}),"\n",(0,s.jsx)(n.h3,{id:"2935-\u5220\u9664\u5c5e\u6027",children:"29.3.5 \u5220\u9664\u5c5e\u6027"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,13-16}",children:'dynamic clay = Clay.Object(new\r\n{\r\n Foo = "json",\r\n Bar = 100,\r\n Nest = new\r\n {\r\n Foobar = true\r\n },\r\n Arr = new string[] { "NOR", "XOR" }\r\n});\r\n\r\n// \u5220\u9664\u64cd\u4f5c\r\nclay.Delete("Foo"); // \u901a\u8fc7 Delete \u65b9\u6cd5\u5220\u9664\r\nclay.Arr.Delete(0); // \u652f\u6301\u6570\u7ec4 Delete \u7d22\u5f15\u5220\u9664\r\nclay("Bar"); // \u652f\u6301\u76f4\u63a5\u901a\u8fc7\u5bf9\u8c61\u4f5c\u4e3a\u65b9\u6cd5\u5220\u9664\r\nclay.Arr(1); // \u652f\u6301\u6570\u7ec4\u4f5c\u4e3a\u65b9\u6cd5\u5220\u9664\n'})}),"\n",(0,s.jsx)(n.h3,{id:"2936-\u5224\u65ad\u952e\u7d22\u5f15\u662f\u5426\u5b58\u5728",children:"29.3.6 \u5224\u65ad\u952e/\u7d22\u5f15\u662f\u5426\u5b58\u5728"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {1,13-18}",children:'dynamic clay = Clay.Object(new\r\n{\r\n Foo = "json",\r\n Bar = 100,\r\n Nest = new\r\n {\r\n Foobar = true\r\n },\r\n Arr = new string[] { "NOR", "XOR" }\r\n});\r\n\r\n// \u5224\u65ad\u5c5e\u6027\u662f\u5426\u5b58\u5728\r\nvar a = clay.IsDefined("Foo"); // true\r\nvar b = clay.IsDefined("Foooo"); // false\r\nvar c = clay.Foo(); // true\r\nvar d = clay.Foooo(); // false;\r\nvar e = clay.Arr.IsDefined(0); // true\r\nvar f = clay.Arr.IsDefined(3); // false\n'})}),"\n",(0,s.jsx)(n.h3,{id:"2937-\u904d\u5386\u5bf9\u8c61",children:"29.3.7 \u904d\u5386\u5bf9\u8c61"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {12,18,24,33,36}",children:'dynamic clay = Clay.Object(new\r\n{\r\n Foo = "json",\r\n Bar = 100,\r\n Nest = new\r\n {\r\n Foobar = true\r\n },\r\n Arr = new string[] { "NOR", "XOR" }\r\n});\r\n\r\n// \u904d\u5386\u6570\u7ec4\r\nforeach (string item in clay.Arr)\r\n{\r\n Console.WriteLine(item); // NOR, XOR\r\n}\r\n\r\n// \u904d\u5386\u6574\u4e2a\u5bf9\u8c61\u5c5e\u6027\u53ca\u503c\uff0c\u7c7b\u4f3c JavaScript \u7684 for (var p in obj)\r\nforeach (KeyValuePair item in clay)\r\n{\r\n Console.WriteLine(item.Key + ":" + item.Value); // Foo:json, Bar: 100, Nest: { "Foobar":true}, Arr:["NOR","XOR"]\r\n}\r\n\r\n// \u6570\u7ec4/\u96c6\u5408 \u53ef\u4f7f\u7528 Lambda \u65b9\u5f0f\uff0cFurion 4.8.7.19+ \u652f\u6301\r\nIEnumerable query = clay.Arr.AsEnumerator(); // \u901a\u8fc7 .AsEnumerator() \u8f6c\u6362\u6210 IEnumerable \u7c7b\u578b\r\nvar result = query.Where(u => u.StartsWith("N"))\r\n .Select(u => new\r\n {\r\n Name = u\r\n })\r\n .ToList();\r\n\r\n// \u4e5f\u53ef\u4ee5\u901a\u8fc7\u539f\u751f\u65b9\u6cd5\u8f6c\u6362\u6210 IEnumerable \u5bf9\u8c61\r\nIEnumerable query = ((System.Collections.IEnumerable)clay.Arr).Cast(); // \u5176\u4e2d Cast \u7684 T \u53ef\u4ee5\u65f6\u4efb\u610f\u7c7b\u578b\uff0c\u6bd4\u5982 Cast();\r\n\r\n// \u83b7\u53d6\u5bf9\u8c61\u6240\u6709\u952e\u6216\u6570\u7ec4\u6240\u6709\u7d22\u5f15\r\nIEnumerable keys = clay.GetDynamicMemberNames();\n'})}),"\n",(0,s.jsx)(n.h3,{id:"2938-\u8f6c\u6362\u6210\u5177\u4f53\u5bf9\u8c61",children:"29.3.8 \u8f6c\u6362\u6210\u5177\u4f53\u5bf9\u8c61"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cs",metastring:"showLineNumbers {5-7,11-13}",children:'dynamic clay = new Clay();\r\nclay.Arr = new string[] { "Furion", "Fur" };\r\n\r\n// \u6570\u7ec4\u8f6c\u6362\u793a\u4f8b\r\nvar a1 = clay.Arr.Deserialize(); // \u901a\u8fc7 Deserialize \u65b9\u6cd5\r\nvar a2 = (string[])clay.Arr; // \u5f3a\u5236\u8f6c\u6362\r\nstring[] a3 = clay.Arr; // \u58f0\u660e\u65b9\u5f0f\r\n\r\n// \u5bf9\u8c61\u8f6c\u6362\u793a\u4f8b\r\nclay.City = new City { Id = 1, Name = "\u4e2d\u5c71\u5e02" };\r\nvar c1 = clay.City.Deserialize(); // \u901a\u8fc7 Deserialize \u65b9\u6cd5\r\nvar c2 = (City)clay.City; // \u5f3a\u5236\u8f6c\u6362\r\nCity c3 = clay.City; // \u58f0\u660e\u65b9\u5f0f\n'})}),"\n",(0,s.jsx)(n.h3,{id:"2939-\u56fa\u5316\u7c98\u571f",children:"29.3.9 \u56fa\u5316\u7c98\u571f"}),"\n",(0,s.jsxs)(n.p,{children:["\u56fa\u5316\u7c98\u571f\u5728\u5f88\u591a\u65f6\u5019\u548c\u5e8f\u5217\u5316\u5f88\u50cf\uff0c\u4f46\u662f\u5982\u679c\u76f4\u63a5\u8c03\u7528 ",(0,s.jsx)(n.code,{children:"Deserialize