Dynamic Object with Dollar on String
c#, winforms
Solution
You can use `JObject`
var obj = JObject.Parse(dog); //(OR JsonConvert.DeserializeObject(dog) as JObject;)
foreach (string view in obj["entry"]["media$group"]["yt$statistics"]["viewCount"])
{
}
Problem
Im usíng this code to get views of video from youtube: ``` WebClient ccn = new WebClient(); string dog = ccn.DownloadString("https://gdata.youtube.com/feeds/api/videos/5WEK6HgXBsQ?v=2&alt=json"); dynamic obj = JsonConvert.DeserializeObject(dog); foreach (string view in obj.entry.media$group.yt$statistics.viewCount) { listBox1.Items.Add(view); } ``` But on string `foreach (string view in obj.entry.media$group.yt$statistics.viewCount)` VS 2013 return error on the `$`-sign. Partial of Youtube json is: ``` "yt$statistics":{ "favoriteCount":"0", "viewCount":"730" }, ``` How would you use this with $?