|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -import pickle |
4 | 3 | from pathlib import Path |
5 | 4 | from typing import TYPE_CHECKING, Any, Awaitable, Callable |
6 | 5 | from urllib.parse import urlencode as urllib_urlencode |
|
9 | 8 | from ..reactive import isolate |
10 | 9 | from ._bookmark_state import local_save_dir |
11 | 10 | from ._types import BookmarkSaveDirFn |
12 | | -from ._utils import in_shiny_server, to_json_str |
| 11 | +from ._utils import in_shiny_server, to_json_file, to_json_str |
13 | 12 |
|
14 | 13 | if TYPE_CHECKING: |
15 | 14 | from .. import Inputs |
@@ -55,7 +54,7 @@ async def _call_on_save(self): |
55 | 54 |
|
56 | 55 | async def _save_state(self, *, app: App) -> str: |
57 | 56 | """ |
58 | | - Save a state to disk (pickle). |
| 57 | + Save a bookmark state to disk (JSON). |
59 | 58 |
|
60 | 59 | Returns |
61 | 60 | ------- |
@@ -91,12 +90,10 @@ async def _save_state(self, *, app: App) -> str: |
91 | 90 | ) |
92 | 91 | assert self.dir is not None |
93 | 92 |
|
94 | | - with open(self.dir / "input.pickle", "wb") as f: |
95 | | - pickle.dump(input_values_json, f) |
| 93 | + to_json_file(input_values_json, self.dir / "input.json") |
96 | 94 |
|
97 | 95 | if len(self.values) > 0: |
98 | | - with open(self.dir / "values.pickle", "wb") as f: |
99 | | - pickle.dump(self.values, f) |
| 96 | + to_json_file(self.values, self.dir / "values.json") |
100 | 97 | # End save to disk |
101 | 98 |
|
102 | 99 | # No need to encode URI component as it is only ascii characters. |
|
0 commit comments