title: Reading a local JSON file from Angular/Nativescript
body: <p>I have tried placing an <code>en.json</code> file in the following locations:</p>
  
  <pre><code>src/assets/i18n/en.json
  src/app/assets/i18n/en.json
  </code></pre>
  
  <p>And I then try to read the file like this:</p>
  
  <pre><code>import {knownFolders, File} from 'tns-core-modules/file-system';
  import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
  import { Observable } from 'rxjs';
  
  export class TranslateFileLoader implements TranslateLoader {
      constructor(public prefix: string = 'assets/i18n/', public suffix: string = '.json') {}
  
      public getTranslation(lang: string): Observable&lt;Object&gt; {
        const appFolder = knownFolders.currentApp(); // Havet tried with knownFolders.documents() also
        console.log(`${this.prefix}${lang}${this.suffix}`);
        const cfgFile = appFolder.getFile(`${this.prefix}${lang}${this.suffix}`);
        console.log(File.exists(cfgFile.path));
        console.log(cfgFile.path);
        const fileData = cfgFile.readTextSync();
        console.log(fileData);
        return JSON.parse(fileData);
      }
  }
  </code></pre>
  
  <blockquote>
    <p>console.log #1: assets/i18n/en.json<br> console.log #2: true<br>
    console.log #3:
    /data/data/org.nativescript.playground/files/app/assets/i18n/en.json<br>
    console.log #4:</p>
  </blockquote>
  
  <p>So yeah, the path seems good, the <code>File.exists(cfgFile.path)</code> returns <code>true</code>, but the <code>fileData</code> is empty and thus I get a exception when I <code>JSON.parse(fileData)</code>. But why? First I thought that the files where not there, but I get true from my exists test. So it seems that the file is there when the device/emulator is running, but I can not read its content?</p>
  
  <p>Any ideas?</p>
  
  <p>Thank you<br>
  Søren</p>