Home > Net >  Invalid JSON files in FireBase
Invalid JSON files in FireBase

Time:07-18

enter image description here

I want to import json file in Realtime Database of firebase but showing error "Invalid JSON file" even though the json in a file is valid and my quota limit has not been disabled yet.My file size is about360 MB .How should I import the json file ?

CodePudding user response:

I noticed that Size of a single write request to the database :

  1. 256 MB from the REST API;

  2. 16 MB from the SDKs.

If you upload JSON files, you have to separate them into multi JSON files (16MB) and upload each one manually.

enter image description here

CodePudding user response:

Frederic Chang Explained very well .But as the json file get overwriten each time you upload So to reduce the manual work of creating each parent node and importing the data I have used the following code.

    $json_data = file_get_contents(getcwd()."/../assets/rescuelane-simulator-default-rtdb-export.json");

foreach ($json_data as $key => $value) {

  $this->myfirebase->firebase()->createDatabase()->getReference("users/".$key)->set($value);

}
  • Related