hi to all..
i take a windows application..in that one button and one textbox...
i wrote code like this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Private void button1_Click(object sender, EventArgs e)
{
string apiUrl = "http://api.geonames.org/citiesJSON?formatted=true&north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo&style=full";
Uri address = new Uri(apiUrl);
System.Net.HttpWebRequest request = System.Net.WebRequest.Create(address) as System.Net.HttpWebRequest;
request.Method = "GET";
request.ContentType = "text/json";
using (System.Net.HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse)
{
System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());
string strOutput = reader.ReadToEnd();
textbox1.text= strOutput.ToString();
}
}
i debug the above code that time i cliked button that json string came in textbox. like this:
{"geonames": [ { "fcodeName": "capital of a political entity",
"countrycode": "MX", "fcl": "P", "fclName": "city, village,...",
"name": "Mexico City", "wikipedia": "", "lng": -99.12766456604,
"fcode": "PPLC", "geonameId": 3530597, "lat": 19.428472427036,
"population": 12294193 }, {
"fcodeName": "capital of a political entity", "countrycode": "PH",
"fcl": "P", "fclName": "city, village,...", "name": "Manila",
"wikipedia": "", "lng": 120.9822, "fcode": "PPLC",
"geonameId": 1701668, "lat": 14.6042, "population": 10444527 }, {
"fcodeName": "capital of a political entity", "countrycode": "BD",
"fcl": "P", "fclName": "city, village,...", "name": "Dhaka",
"wikipedia": "", "lng": 90.40743827819824, "fcode": "PPLC",
"geonameId": 1185241, "lat": 23.710395616597037,
"population": 10356500 }, {
"fcodeName": "capital of a political entity", "countrycode": "KR",
"fcl": "P", "fclName": "city, village,...", "name": "Seoul",
"wikipedia": "", "lng": 126.977834701538, "fcode": "PPLC",
"geonameId": 1835848, "lat": 37.5682561388953, "population": 10349312
}, { "fcodeName": "capital of a political entity", "countrycode": "ID",
"fcl": "P", "fclName": "city, village,...", "name": "Jakarta",
"wikipedia": "", "lng": 106.84513092041016, "fcode": "PPLC",
"geonameId": 1642911, "lat": -6.214623197035775, "population": 8540121
}, { "fcodeName": "capital of a political entity", "countrycode": "JP",
"fcl": "P", "fclName": "city, village,...", "name": "Tokyo",
"wikipedia": "", "lng": 139.581298828125, "fcode": "PPLC",
"geonameId": 1850147, "lat": 35.6148836824544, "population": 8336599
}, { "fcodeName": "capital of a political entity", "countrycode": "TW",
"fcl": "P", "fclName": "city, village,...", "name": "Taipei",
"wikipedia": "", "lng": 121.531846, "fcode": "PPLC",
"geonameId": 1668341, "lat": 25.047763, "population": 7871900 }, {
"fcodeName": "capital of a political entity", "countrycode": "CN",
"fcl": "P", "fclName": "city, village,...", "name": "Beijing",
"wikipedia": "", "lng": 116.397228240967, "fcode": "PPLC",
"geonameId": 1816670, "lat": 39.9074977414405, "population": 7480601
}, { "fcodeName": "capital of a political entity", "countrycode": "CO",
"fcl": "P", "fclName": "city, village,...", "name": "Bogotá",
"wikipedia": "", "lng": -74.08175468444824, "fcode": "PPLC",
"geonameId": 3688689, "lat": 4.609705849789108, "population": 7102602
}, { "fcodeName": "capital of a political entity", "countrycode": "HK",
"fcl": "P", "fclName": "city, village,...", "name": "Hong Kong",
"wikipedia": "", "lng": 114.157691001892, "fcode": "PPLC",
"geonameId": 1819729, "lat": 22.2855225817732, "population": 7012738
}]}
in my textbox output came with special characters like square boxes..how to remove those special characters..
but my scnario is using keyvaluepair and dictionary to get the deserialize output..how?
if any body knows pls let me know..do the need full..
[edit]Code block added - OriginalGriff[/edit]