> For the complete documentation index, see [llms.txt](https://sryu1.gitbook.io/pysettings-manager/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sryu1.gitbook.io/pysettings-manager/save.md).

# Save

save function

Save variables or a dictionary to a JSON file.

### Parameters

* `config_file` (str): The file to save the data to.
* `**kwargs` (Any): The data to save. If a dictionary is passed as the only argument, it will be saved to the JSON file as is. If multiple keyword arguments are passed, they will be combined into a dictionary and saved to the JSON file.

### Raises

* `FileNotFoundError`: If the directory for `config_file` does not exist.
* `PermissionError`: If the file cannot be opened for writing due to insufficient permissions.
* `IOError`: If there is an error writing to the file.

### Example

<pre class="language-python"><code class="lang-python">import pysettings_manager as pysm
# Save a dictionary to a JSON file
settings = {"foo": 1, "bar": "hello"}
<strong>pysm.save("settings.json", **settings)
</strong>
# Save variables to a JSON file
foo = 1
bar = "hello"
pysm.save("settings.json", foo=foo, bar=bar)

# Save and merge multiple dictionaries to a JSON file
settings1 = {"foo": 1, "bar": "hello"}
settings2 = {"baz": 2, "qux": "world"}
pysm.save("settings.json", **settings1, **settings2)
</code></pre>
