# Importing json

{% hint style="info" %}
This can be useful for seeding a firebase project, and or restore a backup.
{% endhint %}

from [Firebase: Import JSON To Cloud Firestore](https://levelup.gitconnected.com/firebase-import-json-to-firestore-ed6a4adc2b57), abridge below

get `users.json`

```
{
  "users": [
    {
      "id": "1",
      "firstName": "Kristin",
      "lastName": "Smith",
      "occupation": "Teacher",
      "reviewCount": "6",
      "reviewScore": "5",
    },
    {
      "id": "2",
      "firstName": "Olivia",
      "lastName": "Parker",
      "occupation": "Teacher",
      "reviewCount": "11",
      "reviewScore": "5"
    },
    {
      "id": "3",
      "firstName": "Jimmy",
      "lastName": "Robinson",
      "occupation": "Teacher",
      "reviewCount": "9",
      "reviewScore": "4"
    },
    {
      "id": "4",
      "firstName": "Zack",
      "lastName": "Carter",
      "occupation": "Teacher",
      "reviewCount": "4",
      "reviewScore": "5"
    },
    {
      "id": "5",
      "firstName": "Brad",
      "lastName": "Rayburn",
      "occupation": "Teacher",
      "reviewCount": "2",
      "reviewScore": "4"
    }
  ]
}
```

\[...]

module `firestore-export-import`

```javascript
// Imports
const firestoreService = require('firestore-export-import');
const firebaseConfig = require('./config.js');
const serviceAccount = require('./serviceAccount.json');

// JSON To Firestore
const jsonToFirestore = async () => {
  try {
    console.log('Initialzing Firebase');
    await firestoreService.initializeApp(serviceAccount, firebaseConfig.databaseURL);
    console.log('Firebase Initialized');

    await firestoreService.restore('./data-clean/firebase/users.json');
    console.log('Upload Success');
  }
  catch (error) {
    console.log(error);
  }
};

jsonToFirestore();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://textav.gitbook.io/firebase-react-notes/firestore/importing-json.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
