[{"data":1,"prerenderedAt":76},["ShallowReactive",2],{"/2025/09/25-xmlserializer-and-boolean":3},{"id":4,"title":5,"body":6,"date":67,"description":47,"extension":68,"meta":69,"navigation":70,"path":71,"robots":72,"seo":73,"stem":74,"__hash__":75},"posts/2025/09/25 XMLSerializer-and-boolean.md","25 XMLSerializer And Boolean",{"type":7,"value":8,"toc":64},"minimark",[9,18,25,28,31,34,48,50,53,61],[10,11,13],"post-title",{":date":12},"date",[14,15,17],"h1",{"id":16},"xmlserializer-and-boolean","XMLSerializer and Boolean",[19,20,21],"notes",{},[22,23,24],"p",{},"This is a repost from my old blog. First posted in 5/5/2017.",[22,26,27],{},"I rewrote a project to utilize XMLSerializer instead of manually append xml tags. It works great until I encountered problem with backward compatibility on Boolean type. Our client is sending boolean value with first letter capitalized. \"True\" and \"False\" and apparently XMLSerializer were unable to deserialize the value as boolean. Because by convention, boolean in XML has to be all lower case. Searching online I found out that I need to do a small trick.",[29,30],"br",{},[22,32,33],{},"Instead of:",[35,36,37],"code-block",{},[38,39,44],"pre",{"className":40,"code":42,"language":43},[41],"language-text","\u003CXmlElement(\"isvalid\")>\nPublic Property IsValid As Boolean\n","text",[45,46,42],"code",{"__ignoreMap":47},"",[29,49],{},[22,51,52],{},"I have to rewrite it as:",[35,54,55],{},[38,56,59],{"className":57,"code":58,"language":43},[41],"\u003CXmlElement(\"isvalid\")>\nPublic Property IsValidString As String\n   Get\n      Return IsValid.ToString().ToLower()\n   End Get\n   Set\n      Boolean.TryParse(value, IsValid)\n   End Set\nEnd Property\n\n\u003CXmlIgnore>\nPublic Property IsValid As Boolean\n",[45,60,58],{"__ignoreMap":47},[22,62,63],{},"The modified version can handle both formats.",{"title":47,"searchDepth":65,"depth":65,"links":66},2,[],"2025-09-25T00:00:00.000Z","md",{},true,"/2025/09/25-xmlserializer-and-boolean",null,{"title":5,"description":47},"2025/09/25 XMLSerializer-and-boolean","qHbTr-Pix9JtxgtHcPP5EzzNp2CrTRy_CpEQdaQZmxc",1785167453081]