I'm started developement in xamarin cross platform development in visual studio. I want to know, how to retrieve the JSON message from url to show the details in table view. Here i give a sample url, how to retrieve all the city name in the json data and show in table. Help me!
Asked
Active
Viewed 1.1k times
3
-
1I'm not familiar with Xamarin.forms, but am in Xamarin.iOS and your question seems too broad in my opinion. one thing is to know how to make a request to the server, another is how to parse the result, and another is how to use the data you have and display it. I think splitting it into a seperate questions will get you more answers. – SuperFrog Oct 28 '14 at 13:01
-
@Udil i have a one more question. Is possible to write a objective C in xamarin? – Satheesh Natarajan Oct 28 '14 at 14:41
-
1. Why would you want to? 2. You cannot write or mix Obj-C with C# in Xamarin. You *can* however, write an obj-c library, then do a c# binding library around it and then consume it in your Xamarin.iOS app. But that sounds like a giant hassle. If you already have the obj-c library is one thing but otherwise I think you would need a really good reason to want to do this. – valdetero Oct 28 '14 at 14:57
2 Answers
3
As @Udi said, your question is too broad. But because of that, I'll give broad answers.
First, use HttpClient to retrieve the data from your url. Second, use Json.Net to deserialize your response into your entities/model.
string url = @"http://api.wunderground.com/api/02e5dd8c34e3e657/geolookup/conditions/forecast/q/Dhaka,Bangladesh.json";
using (var client = new HttpClient())
{
var result = await client.GetStringAsync(url);
return JsonConvert.DeserializeObject<YourModelForTheResponse>(result);
}
Third, to display your data, I would suggest going Xamarin.Forms or MonoTouch.Dialog. It makes using tables way easier.
I have a sample app that I queried a service, got a json response, and displayed the list of data using both Xamarin.Forms and MonoTouch.Dialog. Check out my sample app at github.

valdetero
- 4,624
- 1
- 31
- 46
-
In your example program, u didn't used json at anywhere. And using this code to i refer the response class, but the error was occured in the await. – Satheesh Natarajan Oct 31 '14 at 08:51
-
1. As I stated, your question was vague, so was my answer. 2. I did use JSON. YOUR service and the service in my example returns JSON. I immediately deserialized it into an object once I received it. See the `JsonConvert` line? Why would I want to interact with raw json when JSON.Net can convert it to my model? What more are you looking for? You didn't provide a specific question with a code problem so I wasn't going to do it for you. I gave sufficient answer for what you were asking. – valdetero Oct 31 '14 at 14:29
-
Actually i said your sample app at github program. Now i written my own program, there was no error. But the output was not print. i posted a new question with code. Help me. – Satheesh Natarajan Oct 31 '14 at 14:33
-
[click here](http://stackoverflow.com/questions/26677307/cannot-print-the-json-message-in-listview-using-xamarin-cross-platform) to see new question @valdetero – Satheesh Natarajan Oct 31 '14 at 14:53
3
I posted this question on xamarin forums with complete coding. I got a answer from someone with complete coding structure. Its work for me.
click here to see the link with question and answer. I hope, it works for all u.

Satheesh Natarajan
- 459
- 2
- 7
- 31