title: getting the error like JSON schema is not correct. Enter specified JSON scehma.,Create an Array of Favorite fruits Object
body: <p>0</p>
  
  <p>I have the following assessment which is to Create Array of Favorite Food items object in data.json file.</p>
  
  <p>The Array of Objects should have the following fields :</p>
  
  <p>Name</p>
  
  <p>Type</p>
  
  <p>Price</p>
  
  <p>After writing the JSON data, this file should be imported in loopobject.js.</p>
  
  <p>I tried the above request with the below data.json</p>
  
  <p><strong>data.json</strong></p>
  
  <pre><code>"{[{\"Name\":\"Apple\",\"Type\":\"fruit\",\"Price\":123},{\"Name\":\"pizza\",\"Type\":\"italian\",\"Price\":360},{\"Name\":\"burger\",\"Type\":\"mac&amp;cheese\",\"Price\":321},{\"Name\":\"jangri\",\"Type\":\"sweet\",\"Price\":329}]}"
  </code></pre>
  
  <p><strong>loopObject.js</strong></p>
  
  <pre><code>var json = require('./data.json');
  
  json.forEach(function(object) { console.log(object.Name); });
  </code></pre>
  
  <p><strong>verify.js</strong></p>
  
  <pre><code>const Joi = require('joi');
  const fss =require('fs');
  
  const schema = Joi.array().min(3).has({
      Name: Joi.string().required(),
      Type: Joi.string().required(),
      Price: Joi.number().required(),
  });
  
  var data;
  
  try{
   data = require("./data.json");    
  }catch(e)
  {
   data={};
  }
  
  var XMLWriter = require('xml-writer');
      xw = new XMLWriter;
  
  
  const result = Joi.validate(data, schema);
  
  
  
  
  // You can also pass a callback which will be called synchronously with the validation result.
  Joi.validate(data, schema, function (err, value) {
  if(err==null)
  { console.log("JSON is valid.");
  
  }else{
      console.log("JSON schema is not correct. Enter specified JSON scehma.");
  }
  
  });  
  </code></pre>
  
  <p>i have tried couple of ways, everything looks good,but don't know where i am doing mistake. Could you please help on this??</p>