RestClient client = new RestClient(baseUrl); RestRequest request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("Content-Type", "application/json;charset=UTF-8"); request.AddParameter("application/json", value, ParameterType.RequestBody);
IRestResponse response = client.Execute(request); StringReader sr = new StringReader(response.Content); JsonTextReader jsonReader = new JsonTextReader(sr); JsonSerializer serializer = new JsonSerializer();
UserInfor user = serializer.Deserialize<UserInfor>(jsonReader); return user.rt_info.token; }
IRestResponse response = client.Execute(request); StringReader sr = new StringReader(response.Content); JsonTextReader jsonReader = new JsonTextReader(sr); JsonSerializer serializer = new JsonSerializer();
JsonWord r = serializer.Deserialize<JsonWord>(jsonReader); return r.rt_mapinfo.words; }
5. 輸出感情詞典。
staticvoidSaveToFile(List<Word> lst) { string str = string.Empty; for (int i = 0; i < lst.Count; i++) { str += lst[i] + "\r\n"; }