0

I am using dark sky API for my weather application. How can I get the same formatting like on the website. This is how the formatting looks on the website: https://darksky.net/dev/docs/forecast

And when I try to print the info I get this: https://www.scribd.com/document/330855135/ex

This is my code for printing:

    Console.Write("Please enter the name of the location: ");
    string locationName = Console.ReadLine();
    var location = new GoogleLocationService();
    var point = location.GetLatLongFromAddress(locationName);

    var lat = point.Latitude;
    var lng = point.Longitude;

    using (var client = new WebClient())
    {
        var resStr = client.DownloadString("https://api.darksky.net/forecast/d9b0a7d6636dad5856be677f4c19e4f2/" + lat + "," + lng);
        output = resStr;
    }
    return output;
Cœur
  • 37,241
  • 25
  • 195
  • 267
Michael Lee
  • 67
  • 2
  • 9
  • It seems you have outsourced data critical for the understanding of your question. Please remember to provide all necessary data (code, configuration data, exception name ...) in **the question itself**. If the link dies or changes your question will lose most if not all of its meaning! – Kyll Nov 12 '16 at 16:53
  • Its been reformatted on the website to be human readable, that shouldn't matter when used in code. If you want to make it look pretty anyway see [JSON formatter in C#?](http://stackoverflow.com/questions/4580397/json-formatter-in-c) – Alex K. Nov 12 '16 at 17:11

1 Answers1

0

a good way is to deserialize JSON into C# dynamic obj and get the data through object

dynamic data = JsonConvert.DeserializeObject(resStr);
string summary = data.currently.summary;
string temperature = data.currently.temperature;

for further detail about api you can see its documentation

Usman
  • 4,615
  • 2
  • 17
  • 33