How to change JSON value schema in Javascript
<p>I am fetching data from <code>excelsheet</code> and converting it into the <code>JSON</code> format using <code>xlsx-to-json</code> in Node.js</p>

<p>All the values of JSON data are by default showing on <code>string</code> format like:</p>

<pre><code>var jsonObj = [
 { 
 id: '101', // string
 email: 'user1@test.com',  //string
 name: 'user1',
 dob: '1990-10-10',
 phone: '1234567890', //string
 country: 'England',
 address: 'Building 201-A, Abc, Xyz'
 },
 { 
 id: '102',
 email: 'user2@test.com',  
 name: 'user2',
 dob: '1990-10-11',
 phone: '1234567890',
 country: 'Australia',
 address: 'Building 201-A, Abc, Xyz'
 },
 { 
 id: '103',
 email: 'user3@test.com',  
 name: 'user3',
 dob: '1990-10-12',
 phone: '1234567890',
 country: 'France',
 address: 'Building 201-A, Abc, Xyz'
 }
 ];
</code></pre>

<p>When I'm inserting this <code>json</code> into mongodb all the values are getting stored in <code>string</code> datatype. </p>

<p>What I want to do is to validate all this schema and change its datatype before inserting it into mongodb.</p>

<p>Example: id &amp; phone = <code>number</code> or <code>integer</code>, email, name = <code>string</code>, dob=<code>DATE</code>, address=<code>TEXT</code> and country = <code>ENUM</code></p>

<p>Final output should be like:</p>

<pre><code>var jsonObjResult = [
 { 
 id: 101, //integer
 email: 'user1@test.com', //string 
 name: 'user1', //string
 dob: '1990-10-10', //Date
 phone: '1234567890', //number
 country: ['England', 'Australia', 'France'], // enum
 address: 'Building 201-A, Abc, Xyz' // text
 },
 { 
 id: '102', // integer
 email: 'user2@test.com',  //string
 name: 'user2', // string
 dob: '1990-10-11', //date
 phone: '1234567890', // number
 country: ['England', 'Australia', 'France'], // enum
 address: 'Building 201-A, Abc, Xyz' // text
 },
 { 
 id: '103', //integer
 email: 'user3@test.com',  //string
 name: 'user3', // string
 dob: '1990-10-12', //date
 phone: '1234567890', //number
 country: ['England', 'Australia', 'France'], // enum
 address: 'Building 201-A, Abc, Xyz' // text
 }
 ];
</code></pre>

<p>Any help would be appreciated.</p>