public string ToJson() { if (IsEmpty) { return("{}"); } dynamic jObject = new JObject(); jObject.NAME = Name; jObject.URL = Url; if (!string.IsNullOrEmpty(Download)) { jObject.DOWNLOAD = Download; } if (!string.IsNullOrEmpty(ChangeLog)) { jObject.CHANGE_LOG = ChangeLog; } if (!string.IsNullOrEmpty(ChangeLogUrl)) { jObject.CHANGE_LOG_URL = ChangeLogUrl; } if (!string.IsNullOrEmpty(GitHubUsername)) { jObject.GITHUB = new JObject(); jObject.GITHUB.USERNAME = GitHubUsername; jObject.GITHUB.REPOSITORY = GitHubRepository; jObject.GITHUB.ALLOW_PRE_RELEASE = GitHubAllowPreRelease; } if (!string.IsNullOrEmpty(Version)) { string[] temp = Version.Split('.'); jObject.VERSION = new JObject(); if (temp.Length >= 1) { jObject.VERSION.MAJOR = temp[0]; } if (temp.Length >= 2) { jObject.VERSION.MINOR = temp[1]; } if (temp.Length >= 3) { jObject.VERSION.PATCH = temp[2]; } if (temp.Length >= 4) { jObject.VERSION.BUILD = temp[3]; } } if (!string.IsNullOrEmpty(KspVersion)) { string[] temp = KspVersion.Split('.'); jObject.KSP_VERSION = new JObject(); if (temp.Length >= 1) { jObject.KSP_VERSION.MAJOR = temp[0]; } if (temp.Length >= 2) { jObject.KSP_VERSION.MINOR = temp[1]; } if (temp.Length >= 3) { jObject.KSP_VERSION.PATCH = temp[2]; } } if (!string.IsNullOrEmpty(KspVersionMin)) { string[] temp = KspVersionMin.Split('.'); jObject.KSP_VERSION_MIN = new JObject(); if (temp.Length >= 1) { jObject.KSP_VERSION_MIN.MAJOR = temp[0]; } if (temp.Length >= 2) { jObject.KSP_VERSION_MIN.MINOR = temp[1]; } if (temp.Length >= 3) { jObject.KSP_VERSION_MIN.PATCH = temp[2]; } } if (!string.IsNullOrEmpty(KspVersionMax)) { string[] temp = KspVersionMax.Split('.'); jObject.KSP_VERSION_MAX = new JObject(); if (temp.Length >= 1) { jObject.KSP_VERSION_MAX.MAJOR = temp[0]; } if (temp.Length >= 2) { jObject.KSP_VERSION_MAX.MINOR = temp[1]; } if (temp.Length >= 3) { jObject.KSP_VERSION_MAX.PATCH = temp[2]; } } return(jObject.ToString()); }