c# - Reddit search for key and the value in json data -
i hope can me. i'm beginner json try build programm loads posts subreddit trough json file. dont want save in class creating classes json not option found not every subreddit has same structure obviously.
as example use /r/wallpaper https://www.reddit.com/r/wallpaper/hot.json?count=25
that current code null result dat2 when searchin in jobject
var json = ""; using (webclient client = new webclient()) { json = client.downloadstring("https://www.reddit.com/r/wallpaper/hot.json?count=25"); jobject data = jobject.parse(json); string dat2 = data["url"].value<string>(); } how can search value trough key ? example can thumbnail each post. i'm using json.net.
you need find children , loop through them. each child has own url.
sample code:
var json = ""; using (webclient client = new webclient()) { json = client.downloadstring("https://www.reddit.com/r/wallpaper/hot.json?count=25"); jobject data = jobject.parse(json); var children = data["data"]["children"]; (var = 0; < children.count(); i++) { console.writeline(children[i]["data"]["url"]); } }
Comments
Post a Comment