I'm trying to set an arbitrary path in a JSON structure, and it's hard for me to figure out how to make a simple value ...
I would like to use some SetValue method (path, value) that works like SelectToken, but creates a path if it does not exist and sets the value.
public void SetPreference(string username, string path, string value) { var prefs = GetPreferences(username); var jprefs = JObject.Parse(prefs ?? @"{}"); var token = jprefs.SelectToken(path); if (token != null) {
what I mean by the end of global.defaults.sort is actually { global: { defaults: { sort: { true } } } }
source share