我需要返回一个 json 对象,但出现以下错误:
错误 1 无法将类型“Newtonsoft.Json.Linq.JObject”隐式转换为“System.Collections.Generic.IEnumerable<Newtonsoft.Json.Linq.JObject>”。存在显式转换(您是否缺少演员表?)
谁能帮我解决这个错误?
public static IEnumerable<JObject> GetListOfHotels()
{
const string dataPath = "https://api.eancdn.com/ean-services/rs/hotel/v3/list?minorRev=99&cid=55505&apiKey=key&customerUserAgent=Google&customerIpAddress=123.456&locale=en_US¤cyCode=USD&destinationString=washington,united+kingdom&supplierCacheTolerance=MED&arrivalDate=12/12/2013&departureDate=12/15/2013&room1=2&mberOfResults=1&supplierCacheTolerance=MED_ENHANCED";
var request = WebRequest.Create(dataPath);
request.Method = "POST";
const string postData = dataPath;
var byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/json";
request.ContentLength = byteArray.Length;
var dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
var response = request.GetResponse();
var responseCode = (((HttpWebResponse) response).StatusDescription);
var responseStream = response.GetResponseStream();
var responseReader = new StreamReader(responseStream, Encoding.UTF8);
var responseString = responseReader.ReadToEnd();
var root = JObject.Parse(responseString);
return root;
}