DictionaryResponse <T> InternalReadJson <T>( JsonReader reader, DictionaryResponse <T> existingValue, bool hasExistingValue, JsonSerializer serializer) { if (reader.TokenType == JsonToken.Null) { return(null); } var obj = JObject.Load(reader); var error = (string)obj["error"]; bool hadError = obj.Remove("error"); //var result = new DictionaryResponse<T>(); var result = hasExistingValue ? existingValue : new DictionaryResponse <T>(); foreach (var kvp in obj) { result[kvp.Key] = kvp.Value.ToObject <T>(); } if (hadError) { result.Error = error; } return(result); }
static DictionaryResponse ProcessPoS(DictionaryResponse Data) { for (int i = 0; i < Data.results.Count; i++) { Data.results[i].headword = Data.results[i].headword.Replace('’', '\''); Data.results[i].part_of_speech = new System.Text.StringBuilder(Data.results[i].part_of_speech ?? #if DEBUG "noun." #else "noun" #endif ) .Replace("modal v", "modal verb") .Replace("sfx", "suffix") .Replace("interj", "interjection") .Replace("conj", "conjunction").ToString(); } return(Data); }
public void CreateObjects() { var dicres = new DictionaryResponse { Status = "blah", Duration = "1234", Results = new Dictionary <string, ResultResponse>() }; var listres = new ListResponse { Status = "blah", Duration = "12345", Results = new List <ResultResponse>() }; var res = new ResultResponse { Status = "blah", Description = "More blah", Duration = "12434", Data = new Dictionary <string, string>(), Exception = "" }; }