リストへ問題Deserialising JSONは私がリストにJSON文字列をDeserialising問題を抱えている<T>
TCProjectは、次のとおりです。次のように
[JsonObject(MemberSerialization.OptIn)]
public class TCProject
{
public override string ToString()
{
return Name;
}
[JsonProperty(PropertyName = "archived")]
public bool Archived { get; set; }
[JsonProperty(PropertyName = "description")]
public string Description { get; set; }
[JsonProperty(PropertyName = "href")]
public string Href { get; set; }
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
[JsonProperty(PropertyName = "webUrl")]
public string WebUrl { get; set; }
}
JSON文字列を検索します:
{"project":[{"name":"GCUK","id":"project11","href":"/httpAuth/app/rest/projects/id:project11"},{"name":"Interiors In Spain","id":"project3","href":"/httpAuth/app/rest/projects/id:project3"}]}
文字列を変換するコードは次のとおりです。
public IEnumerable<TCProject> GetAllProjects()
{
var uri = _connection.CreateUri("/httpAuth/app/rest/projects");
var request = _connection.Request(uri);
var projects = JsonConvert.DeserializeObject<List<TCProject>>(request);
return projects;
}
私は取得しています
例外:
Newtonsoft.Json.JsonSerialisationException:{ "型にJSONオブジェクトをデシリアライズすることはできません 'System.Collections.Generic.List`1 [TCProject]'"}
私は行方不明の何かが本当に簡単になってしまっています。
これを受け取った方法はどのように見えますか? – jcolebrand
メソッド全体が現在存在しています - _connection.RequestはJSON文字列を返すだけです - それは特別なことをしません – stack72
ああ、これは一般的にSilverlightの問題であることを認識しただけです。なぜ私はVSでそのライブラリを解決することができなかったのかを理解してください... – jcolebrand