Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON.Net and Linq
    primarykey
    data
    text
    <p>I'm a bit of a newbie when it comes to linq and I'm working on a site that parses a json feed using json.net. The problem that I'm having is that I need to be able to pull multiple fields from the json feed and use them for a foreach block. The documentation for json.net only shows how to pull just one field. I've done a few variations after checking out the linq documentation, but I've not found anything that works best. Here's what I've got so far:</p> <pre><code> WebResponse objResponse; WebRequest objRequest = HttpWebRequest.Create(url); objResponse = objRequest.GetResponse(); using (StreamReader reader = new StreamReader(objResponse.GetResponseStream())) { string json = reader.ReadToEnd(); JObject rss = JObject.Parse(json); var postTitles = from p in rss["feedArray"].Children() select (string)p["item"], //These are the fields I need to also query //(string)p["title"], (string)p["message"]; //I've also tried this with console.write and labeling the field indicies for each pulled field foreach (var item in postTitles) { lbl_slides.Text += "&lt;div class='slide'&gt;&lt;div class='slide_inner'&gt;&lt;div class='slide_box'&gt;&lt;div class='slide_content'&gt;&lt;/div&gt;&lt;!-- slide content --&gt;&lt;/div&gt;&lt;!-- slide box --&gt;&lt;/div&gt;&lt;div class='rotator_photo'&gt;&lt;img src='" + item + "' alt='' /&gt;&lt;/div&gt;&lt;!-- rotator photo --&gt;&lt;/div&gt;&lt;!-- slide --&gt;"; } } </code></pre> <p>Has anyone seen how to pull multiple fields from a json feed and use them as part of a foreach block (or something similar? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload