Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
561 views
in .Net Framework by 36 42 54
I am working on web application and i want to read collection of sites from JsonFile with name 'checkList.json' and open all in broswer using c#

1 Answer

0 like 0 dislike
by 36 42 54
selected by
 
Best answer

How to read sites url from Json file and open URLs into browser

To read sites url from Json file and open URLs into browser, Here are the steps to achieve this:

1) Add checkList.json to your application .
2) Add many sites with name Like

{
  "CheckListScenario": [
    {
      "URL": "http://www.google.com",
      "Key": "google"
    },
    {
      "URL": "http://facebook.com",
      "Key": "facebook"
    }
  ]
}

3) Read data from Json

string jsonString = System.IO.File.ReadAllText(jsonPath);

4) DeserializeObject from Json to mapping Classes

CheckListScenarioTest checklist = JsonConvert.DeserializeObject<CheckListScenarioTest>(jsonString);

5) Adding URL into List and Open site automatically in browser

foreach (var item in checklist.CheckListScenario)
{
    ListOfSites.Add(item.URL);
   Process.Start(item.URL);
}
If you don’t ask, the answer is always NO!
...