This is kind of a two part question. I suppose the first is, am I going the best way about doing this and the second is the roadblock I've hit. The following code works for string properties but not for example an int. I get the int value out of the KVP as a string but I can't set an int to a string on the property. I can't find the syntax that lets me parse.
[WebInvoke(UriTemplate = "", Method = "POST")]
public Response Post(JsonValue items)
{
List<Provider> providers = new List<Provider>();
foreach (var item in items)
{
var json = item.Value;
var provider = new Provider();
foreach (var property in typeof(Provider).GetProperties())
{
if (json.ContainsKey(property.Name))
property.SetValue(provider, json[property.Name].ToString(), null);
}
providers.Add(provider);
}
return new Response { success = true, data = providers };
}