KeyRoutines
StepFreefile.writeJson

Change a single value in a JSON file from a routine

Write JSON value sets one value inside a JSON file and leaves the rest of the document as it was. Use it to save a counter, a last-run date, or a setting another tool reads.

How it works

  • Pick the file, the value's path (like settings.volume) and the new value: text, a number, true or false, or JSON.
  • Missing objects and lists along the path are created for you, and so is the file if it doesn't exist.
  • Other parts of the file are kept as they were.
  • A dry run only says what it would write, and a folder trigger on that folder doesn't fire for this write.

Routines that use it

Save when you last backed up

After Zip files finishes, write today's date into a small status file that the next run reads back.

Keep a running total

Read a count, add one with Calculate, and write it back after each finished download.

Flip a setting for an app

Before Open app starts a tool that reads a JSON config, set the option you want for this session.

Settings

SettingWhat it does
PathThe JSON file. It is created when missing.
Value pathWhich value to set, like settings.volume or profiles[0].name. Keep empty to replace the whole file.
ValueThe value: text, a number, true/false, or JSON.

Good to know

  • Changing a file that already exists isn't undone by Undo file moves.

Questions

Will writing one value erase the rest of my JSON file?
No. Only the value at the path you give changes; everything else is kept.
Can it create a new JSON file?
Yes. If the file doesn't exist it is created, with the objects the path needs.

Pairs well with

Build this routine in KeyRoutines

Free from the Microsoft Store for Windows 11 and 10. Pro is a one-time upgrade.