解析值时遇到意外字符:<。路径 '',第 0 行,位置 0。同时通过 mashape 调用炼金术 api
Unexpected character encountered while parsing value: <. Path '', line 0, position 0. while calling alchemy api through mashape
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 响应的 类
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.
我在 url 中犯了一个错误。 url 是“https://alchemy.p.mashape.com/text/TextGetRankedKeywords?outputMode=json&text=”
此外,我需要在 JsonData class
中创建关键字对象的数组实例
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 响应的 类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.
我在 url 中犯了一个错误。 url 是“https://alchemy.p.mashape.com/text/TextGetRankedKeywords?outputMode=json&text=” 此外,我需要在 JsonData class
中创建关键字对象的数组实例