ksmit799
Hey everyone,
I’m wondering what’s the best way to programmatically create an empty JSON object (file), populate it with some data and then save it to the file system. An abridged version of what I’m trying to do is below, however, when saving the file it only contains the text ‘null’ and nothing else. Any help would be appreciated.
// Creating the *new* JSON file.
settings_ = context_->CreateObject<JSONFile>();
// The root object seems to be the issue?
// It appears as if it is null unless you load an existing JSON file.
JSONValue root = settings_->GetRoot();
// Create some dummy data.
root.Set("test", "it works");
// Save the new JSON file.
settings_->SaveFile(path);
Expected file contents:
{ “test”: “it works”}
Actual file contents:
null