# writeJsonToFile

Write JSON data to a file to retrieve later via [`readJsonFromFile`](/application-development/lampixjs/api/readjsonfromfile.md).

## Returns

(`Promise<void>`): A promise that fulfills without arguments when writing has finished.

## Example

```javascript
import lampix from '@lampix/core';

const data = {
  answerToLife: 42
};

lampix.writeJsonToFile('answers.json', data)
  .then(() => console.log('Successfully saved all answers.'));
```

## Notes

[`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) API is also enabled. You can use it instead of this method. `localStorage`, by design, is a blocking I/O operation (synchronous). Use `writeJsonToFile` and [readJsonFromFile](/application-development/lampixjs/api/readjsonfromfile.md) if you want to use non-blocking (asynchronous) I/O operations.

`writeJsonToFile` (like `localStorage`), is application specific. This means one application cannot retrieve the saved data of another application.


---

# 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://api.lampix.co/application-development/lampixjs/api/writejsontofile.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.
