Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How can Xamarin.Forms class access JSON from REST WCF service?

$
0
0

Hi,

I'm learning all about Xamarin.Forms, so please bear with me. This may seem like a simple question, but finding a solution has been an uphill battle.

This code snippet is from a class in my Xamarin.Forms project that loops through a json stream. I use the Newtonsoft library for the json:

string ar = "[{\"lon\":\"-66.105721\",\"lat\":\"18.466333\"},{\"lon\":\"-65.827385\",\"lat\":\"18.149683\"}]";
var obj = JsonConvert.DeserializeObject(ar);
string lat = string.Empty;
string lon = string.Empty;

foreach (var item in ((JArray)obj))
{
    lat = item.Value<string>("lat");
    lon = item.Value<string>("lon");
}

This works as expected.

Now, instead of being that string, it will be a JSON stream returned by calling URL http//IP/Service1.svc/GetTableData (the forum doesn't let me post URLs). This URL will return the same exact json stream that was used in the snippet above:

[{"lon":"-66.105721","lat":"18.466333"},{"lon":"-65.827385","lat":"18.149683"}]

My question: How can my class in the Xamarin.Forms project call the URL and read the json being returned? I only have access to the URL, so I can't add it to my project as a service reference.

I'm using Visual Studio 2017.

Any help is appreciated.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>