static void Main(string[] args) { string jsonString = string.Empty; if (GetJsonString.ReadFromFile(@".\..\..\JSON.txt", out jsonString) == false) { return; } JsonModel model = JsonToModel.StringToModel(jsonString); try { ResultOutput.Print(model.arrayOne, "ArrayOne"); ResultOutput.Print(model.arrayTwo, "ArrayTwo"); var Info = new InfoStr(); ResultOutput.Print(TestRequest.GetUniqueValues(model.arrayOne, model.arrayTwo), Info.uniqueStr); ResultOutput.Print(TestRequest.GetOddNumbers(model.arrayOne, model.arrayTwo), Info.oddNbrStr); ResultOutput.Print(TestRequest.GetEvenNbrSum(model.arrayOne, model.arrayTwo), Info.sumStr); } catch (ArgumentNullException) { Console.WriteLine("EmptyArray"); } catch (OverflowException) { Console.WriteLine("Overflow!"); } Console.ReadLine(); }
/// <summary> /// 获取结果 /// </summary> /// <returns>json格式结果</returns> public string GetJsonSource() { string pa = ","; try { StringBuilder returnValue = new StringBuilder("{ \"total\":\" " + Total.ToString() + "\", \"rows\":["); if (Rows.Count > 0) { foreach (var item in Rows) { string josnItem = JsonToModel.ConvertJosnForDataGird <T>(item); josnItem = josnItem.Replace("\r\n", ""); returnValue.AppendLine(josnItem); if (!Rows.Last().Equals(item)) { returnValue.AppendLine(pa); } } //returnValue.Remove(rows.Count - 1, 1); } returnValue.Append("]}"); return(returnValue.ToString()); } catch (Exception) { throw; } }
public ActionResult Index() { JsonToModel js = new JsonToModel(); var model = js.Distribute(); return(View(model)); }
public void IncorrectInputString() { string jsonString = null; JsonModel expected = null; JsonModel model = JsonToModel.StringToModel(jsonString); //assert Assert.AreEqual(expected, model); }
public static bool PostSend(string url, string ids) { string str = HttpHelp.SendPost(url, ids); var model = JsonToModel.FromJSON <UpDataResponse>(str); if (model.status == 1) { return(true); } else { return(false); } }
public static bool GetSend(string url) { //string[] arrTemp = "abc,abcd,abcdef,abcdefg,abcdefgh".Split(','); string str = HttpHelp.SendGet(url); var model = JsonToModel.FromJSON <TitleInfoResponse>(str); if (model.status == 1) { return(true); } else { return(false); } }
public async Task <List <ItemCategory> > AllR10Categories() { List <ItemCategory> R10Categories = new List <ItemCategory>(); using (var client = new HttpClient()) { String SessionId = await GetSessionId(); var Categoriesuri = Resources.RGWIP + "RetailGateway/api/catalog/v1/stores/0/products/categories?type=Merchandise"; client.DefaultRequestHeaders.Add("Retailer", "Retailer"); client.DefaultRequestHeaders.Add("TouchPoint", "SelfScanDevice"); client.DefaultRequestHeaders.Add("R10SessionId", SessionId); HttpResponseMessage response2 = await client.GetAsync(Categoriesuri); var CategoryResponse = await response2.Content.ReadAsStringAsync(); R10Categories = JsonToModel.MapFields(CategoryResponse); } return(R10Categories); }
public async Task <List <ItemCatalogueModel> > GetR10ServiceItems(long ItemCategoryId) { List <ItemCatalogueModel> R10Categories = new List <ItemCatalogueModel>(); using (var client = new HttpClient()) { String SessionId = await GetSessionId(); var Categoriesuri = Resources.RGWIP + "RetailGateway/api/catalog/v1/stores/10072/products?category=" + ItemCategoryId + "&startIndex=0&count=100"; client.DefaultRequestHeaders.Add("Retailer", "Retailer"); client.DefaultRequestHeaders.Add("TouchPoint", "SelfScanDevice"); client.DefaultRequestHeaders.Add("R10SessionId", SessionId); client.DefaultRequestHeaders.Add("TouchPointID", "100"); HttpResponseMessage response2 = await client.GetAsync(Categoriesuri); var CategoryResponse = await response2.Content.ReadAsStringAsync(); R10Categories = JsonToModel.MapItemFields(CategoryResponse); } return(R10Categories); }