'Using WebClient DownloadString, how can I get a JSON API Result in plaintext?
I would like to make the text plaintext rather than JSON formatting. How can I accomplish this? I've searched around but I haven't been able to come across a quick and easy solution that works. Having tried for a long time, I apologise in advance if this seems like a ridiculous question.
Here is my code:
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
string pubIp = new System.Net.WebClient().DownloadString("https://vpnapi.io/api/?key=APIKEY");
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
textBox1.Text = "IP Address: " + pubIp + System.Environment.NewLine;
It currently appears as this (but line by line):
{
"ip": "1.1.1.1.1.1",
"security": {
"vpn": false,
"proxy": false,
"tor": false,
"relay": false
},
"location": {
"city": "Location",
"region": "Location",
"country": "Location",
"continent": "Location",
"region_code": "Location",
"country_code": "Location",
"continent_code": "Location",
"latitude": "-00.0000",
"longitude": "000.0000",
"time_zone": "Location",
"locale_code": "en",
"metro_code": "",
"is_in_european_union": false
},
"network": {
"network": "1.111.1.1/11",
"autonomous_system_number": "111111",
"autonomous_system_organization": "ISP"
}
}
I would like it to appear like this:
ip: 1.1.1.1.1.1
security vpn:
false proxy:
false tor:
false relay: false
location: city:
Location region:
Location country:
Location continent:
Location region_code:
Location country_code:
Location continent_code:
Location latitude: -00.0000
longitude: 000.0000 time_zone:
Location locale_code:
metro_code:
is_in_european_union": false
network network: 1.111.1.1/11
autonomous_system_number: 111111
autonomous_system_organization: ISP
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
