title: Import JSON with mongo script
body: <p>I'm trying to write a <strong>mongo script</strong> to import a <code>jsonArray</code> from a <code>JSON</code> file. My script is in <code>.js</code> format and I execute it with <code>load()</code> command in <strong>mongo shell</strong>. Is it possible to do it with a <code>mongo script</code>?</p>
  
  <p>I know I can use <code>mongoimport</code> instead. But I want to know a way to do it with a script.</p>
  
  <p>The contents of my current script in which the import part is missing is given below..</p>
  
  <pre><code>var db = connect("localhost:27017/fypgui");
  //Import json to "crimes" collection here 
  var crimes = db.crimes.find();
  while (crimes.hasNext()){
      var item = crimes.next();
      var year =(item.crime_date != null)?(new Date(item.crime_date)).getFullYear():null;
      db.crimes.update( {_id: item._id}, {$set: {crime_year: year}});
  }
  </code></pre>