Esempio n. 1
0
        private JObject read_and_parse_json_file(string path, bool isGithubPath = false)
        {
            var res = new JObject();

            try
            {
                JObject ssjsn;
                if (isGithubPath)
                {
                    if (_githubService.IsExistPath(path, UserSettings.GithubUserName, UserSettings.GithubToken, UserSettings.MonicaResultsPathOnGithub))
                    {
                        //_githubService.get
                        ssjsn = JObject.Parse(_githubService.GetFileContent(path, UserSettings.GithubUserName, UserSettings.GithubToken));
                    }
                    else
                    {
                        throw new FileNotFoundException();
                    }
                }
                else
                {
                    ssjsn = JObject.Parse(File.ReadAllText(path));
                }

                res.Add("result", ssjsn);
                res.Add("errors", new JArray());
                res.Add("success", true);
            }
            catch (Exception ex)
            {
                res.Add("result", new JObject());
                res.Add("errors", "Error opening file with path: '" + path + "'!");
                res.Add("success", false);
            }
            return(res);
        }