2015-08-17 53 views
0
public class keywords 
{ 
    [JsonProperty(PropertyName = "text")] 
    public string text { get; set; } 
    [JsonProperty(PropertyName = "relevance")] 
    public string relevance { get; set; } 
} 
public class JsonData 
{ 
    [JsonProperty(PropertyName = "status")] 
    public string status { get; set; } 
    [JsonProperty(PropertyName = "usage")] 
    public string usage { get; set; } 
    [JsonProperty(PropertyName = "url")] 

    public string url { get; set; } 
    [JsonProperty(PropertyName = "language")] 
    public string language { get; set; } 
    [JsonProperty ("keywords")] 
    public keywords keyword { get; set; }  
} 

上面是我用來反序列化通過調用鍊金API接收的json響應的類。解析值時遇到意外的字符:<。路徑'',第0行,位置0.同時通過mashape調用鍊金術api

string url =  "https://alchemy.p.mashape.com/Text/TextGetRankedKeywords?outputMode=json&text=" + text; 
var response = (Unirest.get("https://alchemy.p.mashape.com/Text/TextGetRankedKeywords?outputMode=json&text=" + text) 
    .header("X-Mashape-Key", "AlZVYH30C9mshLPNM7KiE48aFfTHp1h3A31jsnmVPccxBzW5uB") 
    .header("Accept", "application/json") 
    .asJson<JsonData>() 
    .Body); 
var status = response.keyword.text; 
var score = response.keyword.relevance; 

我收到此錯誤:

An exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.dll but was not handled in user code

Additional information: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

+1

請修復代碼格式化 –

+0

我有固定的代碼格式 – Kanwal

+0

你能請張貼發送到該服務的數據? – brannmar

回答

相關問題