Sayed Ahmed
Some C# Stuff (or similar) as I used
HP var_dump in C# to dump array or objects?
http://stackoverflow.com/questions/23824899/php-var-dump-in-c-sharp-to-dump-array-or-objects
How to pass an object array from javascript to server
http://stackoverflow.com/questions/12229530/how-to-pass-an-object-array-from-javascript-to-server
How to Convert JSON object to Custom C# object?
http://stackoverflow.com/questions/2246694/how-to-convert-json-object-to-custom-c-sharp-object
The following did work for me
JavaScriptSerializer serializer = new JavaScriptSerializer();
var jsonObject = serializer.Deserialize<dynamic>(json);
name = (string)jsonObject["user"]["name"];
teamname = (string)jsonObject["user"]["teamname"];
email = (string)jsonObject["user"]["email"];
players = jsonObject["user"]["players"];
}
You could use newtonsoft.json or similar.
My case was little more complicated, JSON string representing: arrays of objects of arrays ofobjects. You could also define the class and could do without dynamic and using Newtonsoft's DeSerialize
C# Parsing JSON array of objects
http://stackoverflow.com/questions/19910476/c-sharp-parsing-json-array-of-objects
The following might also work
string json = "{'results':[{'SwiftCode':'','City':'','BankName':'Deutsche Bank','Bankkey':'10020030','Bankcountry':'DE'},{'SwiftCode':'','City':'10891 Berlin','BankName':'Commerzbank Berlin (West)','Bankkey':'10040000','Bankcountry':'DE'}]}";
var resultObjects = AllChildren(JObject.Parse(json))
.First(c => c.Type == JTokenType.Array && c.Path.Contains("results"))
.Children<JObject>();
foreach (JObject result in resultObjects) {
foreach (JProperty property in result.Properties()) {
// do something with the property belonging to result
}
}
From: http://sitestree.com/?p=2052
Categories:Root, By Sayed Ahmed
Tags:
Post Data:2015-06-30 18:13:33
Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada