title: How to fast insert a JSON into Realm Database for a React Native App
body: <p>I'm designing an offline app using React Native and Realm. One of the features is downloading data from the web API before going offline.The downloaded data is a long JSON. For example:</p>
  
  <pre><code>[{"EventID":"3769","EventName":"Birthday Party","EventDate":"Jun 21 2018  4:00 PM"},{"EventID":"4232","EventName":"Homecoming","EventDate":"Jun 22 2018 11:00 PM"}, {"EventID":"3838","EventName":"the Summer Show","EventDate":"Jun 28 2018  2:00 AM"}]
  </code></pre>
  
  <p>There are many examples of how to insert one entry in Realm, such as:</p>
  
  <pre><code>realm.write(() =&gt; {
    Event.push({EventID: 3769, EventName: 'Birthday Party'});
    Event.push({EventID: 4232, EventName: 'Homecoming'});
  });
  </code></pre>
  
  <p><strong>But is there a way to bulk insert JSON into a Realm table at once?</strong></p>
  
  <p>Many thanks!!!</p>
  
  <hr>
  
  <p><strong>Update</strong> - Works!</p>
  
  <p>I've tried geisshirt's solution (thanks!) with codes below. It takes about 10sec to import a JSON String with 50,000 entities. (Each entity has ID, name and date properties). One trick is that debug mode is much slower than running on the real app. </p>
  
  <p>React Native Code:</p>
  
  <pre><code>axios.get('https://APISERVER/XX/GET_EVENTS')
   .then(response =&gt; {
     Realm.open({
       schema: [{ name: 'Events', properties: { EventID: 'string', EventName: 'string', EventDate: 'string' } }]
     }).then(realm =&gt; {
       realm.write(() =&gt; {
          response.data.forEach(obj =&gt; {
              realm.create('Events', obj);
          });
      });
   })
  </code></pre>
  
  <p>Thanks again!</p>