I have 8 key/value pairs in one JSON URL. I have only 4 matched records in a column. I need to display only 4 matching records in view. I have created One dict model and other list model. ModelList Compare
As per screenshot i need first values from dict like values from list so that i can able to populate json records in view page.
Dict1:
public void GetList1Void()
{
string strAPIUrl = "https://raw.githubusercontent.com/wedeploy-examples/supermarket-web-example/master/products.json";
string jsonUrlProducts;
using (WebClient client = new WebClient())
{
jsonUrlProducts = client.DownloadString(strAPIUrl);
}
Dictionary<string, object> Jsondictresults = new Dictionary<string, object>();
var objResponseB = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(jsonUrlProducts);
foreach (Dictionary<string, object> DictMainKV in objResponseB)
{
foreach (KeyValuePair<string, object> item in DictMainKV)
{
Jsondictresults.Add(item.Key, item.Key);
}
break;
}
ViewBag.VBList1Void = Jsondictresults.Keys;
ViewData["VdataList1Void"] = Jsondictresults;
}
List2:
public List<K360mapMaster> GetList2()
{
List<K360mapMaster> mappingListDb = new List<K360mapMaster>();
var query = from K360mapMaster in _context.K360mapMasters
select K360mapMaster;
var mappings = query.ToList();
foreach (var mappingData in mappings)
{
mappingListDb.Add(new K360mapMaster()
{
ClientCatalog = mappingData.ClientCatalog
});
}
return mappingListDb;
}
Insert table design