Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6705665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:25:49+00:00 2026-05-26T07:25:49+00:00

I was trying to parse this using System.Json but I’m a bit confused how

  • 0

I was trying to parse this using System.Json but I’m a bit confused how to use LINQ on this. The JSON string returned was something like:

{"SearchResults":[{"PageCount":"1"},
{"SEARCHVAL":"Result","CATEGORY":"Category1","X":"1","Y":"2"},
{"SEARCHVAL":"AnotherResult","CATEGORY":"Category1","X":"2","Y":"2"}]}

My code starts out as:

WebClient client = new WebClient();
client.OpenReadCompleted +=
    new OpenReadCompletedEventHandler(client_OpenReadCompleted);
client.OpenReadAsync(uri);

then proceeds to the event handler where the result is stored in a Stream. Any example how to get just the SEARCHVALs, CATEGORYs, Xs and Ys from the stream using LINQ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:25:50+00:00Added an answer on May 26, 2026 at 7:25 am

    The DataContractJSonSerializer is one way to do it but the presence of the “PageCount” object makes its use awkard. It looks to me as though someone has goofed on the server end, it would make much more sense to have the page count a property of the outer object and therefore leave the search results array to contain an homogeneous set of objects.

    The System.Json namespace is handy for this sort of JSON since its very flexible.

    JsonObject searchResults = (JsonObject)JsonValue.Load(e.Result);
    

    Now you could use some Linq to get a set of objects out of this but first so we need to create a DTO type for it:-

     public class SearchResult
     {
          public string SearchValue {get; set;}
          public string Category {get; set;}
          public string X {get; set;}
          public string Y {get; set;}
     }
    

    So now the results query is:-

    var resultList = ((JsonArray)searchResults["SearchResults"])
       .OfType<JsonObject>()
       .Where(o => o.ContainsKey("SEARCHVAL"))
       .Select(o => new SearchResult() { 
           SearchValue = o["SEARCHVALUE"],
           Category = o["CATEGORY"].
           X = o["X"],
           Y = o["Y"]
       }).ToList();
    

    The resultList is List<SearchResult> which you can now bind into some Xaml for display.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse a processing instruction like this using StAX: <?item something=<some_element></some_element>?> StAX
I'm trying to parse a html doc using some code I found from this
I'm trying to parse this XML string: <?xml version=1.0 encoding=UTF-8 standalone=no?> <response type=success> <lots>
Trying to parse some XML but apparently this is too much for a lazy
I am trying to parse the contents of http://feeds.feedburner.com/riabiz using XDocument.Parse(string) (because it gets
I am trying to parse a plain text file using Tika but getting inconsistent
I have an issue while trying to parse an Xml to Objects using Linq
I'm trying to send a JSON string, from an Android 2.3 application, using Java
I am trying to parse this content using jsoup. <div class=imageInlineCenter style=width: 468px; align=center><img
i am trying to parse the title of this content using JSOUP.. <div class=article>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.