title: How to map XML to JSON using type info from XSD (XML Schema) and C#/.NET
body: <p><strong>The problem</strong>: When converting from XML to JSON, quotation marks should only be used for strings and not be used for numbers, booleans, etc</p>
  
  <p>The following XML:</p>
  
  <pre><code>&lt;root&gt;
      &lt;someNumber&gt;22&lt;/someNumber&gt;
      &lt;someBoolean&gt;true&lt;/someBoolean&gt;
      &lt;someString&gt;23&lt;/someString&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Should be mapped to this JSON:</p>
  
  <pre><code>{
      root: {
          someNumber: 22,
          someBoolean: true,
          someString: "23"
      }   
  }
  </code></pre>
  
  <p>And not this:</p>
  
  <pre><code>{
      root: {
          someNumber: "22",
          someBoolean: "true",
          someString: "23"
      }   
  }
  </code></pre>
  
  <p>Using type information from the XSD:</p>
  
  <pre><code>&lt;xs:complexType name="someComplexType"&gt;
      &lt;xs:all&gt;
          &lt;xs:element name="someNumber" type="xs:integer"/&gt;
          &lt;xs:element name="someBoolean" type="xs:boolean"/&gt;
          &lt;xs:element name="someString" type="xs:string"/&gt;
      &lt;/xs:all&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <hr>
  
  <p>Currently I'm using <a href="https://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_JsonConvert_SerializeXNode_2.htm" rel="nofollow noreferrer">JsonConvert.SerializeXNode</a> (from <a href="https://www.newtonsoft.com/json" rel="nofollow noreferrer">Newtonsoft Json.NET</a>)</p>
  
  <p>I have all the type information in the XSD (Xml Schema), and do not want to add any additional type information using XML attributes, as suggested when using JsonConvert.SerializeXNode.</p>
  
  <p>Is it possible to provide the XSD when converting from JSON to XML?</p>
  
  <p>Could anyone please point me in the right direction?</p>