Saving Changes - machitgarha/JsonFile GitHub Wiki

Made changes to your data? Good! It's time to save it to the file:

$jsonFile->save();

What JSONFile::save() does is getting the data as a JSON string and write it to the file. By default, this method saves data as pretty printed JSON, which is a pretty-styled JSON string. You can use different options using JSON constants. As an example, if you want to save data with a pretty style and force data to use objects instead of arrays (i.e. convert all arrays to objects), you can do:

$jsonFile->save(JSON_FORCE_OBJECT | JSON_PRETTY_PRINT);