@Wharp we don’t have a general function that allows writing to JSON because it’s super dangerous! What if you accidentally overwrite some game files? Instead we have a datastore that you can instantiate inside any lua component called __saved_variables or inside any lua class called self._sv that will save data for you. From javascript to save data to such a datastore you want to make a call handler that will direct you to a lua file, and then make a function on that lua file that will save your data (and extract it when you need it).
As an example, check out how we place items in the world. Start with stonehearth_client.js, and look at the function_placeItemOrItemType. This function does a radiant.call, which calls stonehearth:choose_place_item_location.
Choose_place_item_location is defined as a function endpoint in manifest.json, and it’s implement in place_item_call_handler.lua. From place_item_call_handler.lua, we can get to something like town.lua, which has a self._sv inside of it that you can use to save things.
We do have C++ functions that will write to JSON directly but they’re buried explicitly under user_settings and building_template code, so that you can’t accidentally mess with them. 