3

I have a link like translate.google.com/translate_a/t?client=t&text=like&hl=en&sl=en&tl=bn&ie=UTF-8&oe=UTF-8&multires=1&otf=2&ssel=4&tsel=0&otf=1&ssel=4&tsel=0&sc=1.

Here in text=like it will change like text=book text=pen, which means it will be my input word, and I will loop it for 1000 times.

I'm making a dictionary. The above url outputs JSON data.

I want to loop through 1000 words and get their json output into one text file - how can I do that in c#?

Christian Stewart
  • 15,217
  • 20
  • 82
  • 139
ImonBayazid
  • 1,066
  • 3
  • 16
  • 41
  • Wow, unaccept and reaccept? All he's done is paste code for you, it's a bad habit to just take code and use it instead of trying to learn it yourself.. – Christian Stewart Mar 16 '13 at 18:47

2 Answers2

3

see this sample maybe usfull

Person person = GetPerson();


    using (FileStream fs = File.Open(@"c:\person.json", FileMode.CreateNew))
    using (StreamWriter sw = new StreamWriter(fs))
    using (JsonWriter jw = new JsonTextWriter(sw))
    {
      jw.Formatting = Formatting.Indented;

      JsonSerializer serializer = new JsonSerializer();
      serializer.Serialize(jw, person);
    }
0

You will want to query for the JSON data, and parse it using c# JSON.

This question contains extensive information about how to parse JSON.

You can download the JSON by querying that page, using WebClient ToString. You can then pass this into the JSON parser.

Depending on what you want to do with the data (you're not very clear on this), you can then use the JSON object to manipulate it.

Alternatively, if you just want to download the data to a file, you can use WebClient DownloadFile.

Community
  • 1
  • 1
Christian Stewart
  • 15,217
  • 20
  • 82
  • 139
  • If you go to link you can see that file is always saved.How can i save the text of that link into my colletion.txt file??? do u explain elaborately .. – ImonBayazid Mar 04 '13 at 17:14
  • It's not SAVED, it's returned to your browser. If you want to save it to your text file, use the "WebClient ToString" part of my answer, then append it to your file. – Christian Stewart Mar 04 '13 at 17:55