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 6799135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:48:45+00:00 2026-05-26T18:48:45+00:00

I already have the answer for this using silverlight’s System.JSON but specs got changed

  • 0

I already have the answer for this using silverlight’s System.JSON but specs got changed and now I need to do it in .NET 3.5

here’s the JSON I’m getting

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

and the solution using System.JSON assembly was

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();

I figure most of the code is similar/exactly the same but I’m not sure about the ContainsKey’s counterpart in JSON.net. I think it’s the Contains() method but I’m not exactly sure how to use it so that I could get the X and Y of the SEARCHVAL.

UPDATE:

so here’s my code to get the JSON stream and parsing:

       ...
       Uri uri = new Uri(url);

       WebClient client = new WebClient();
       ParseJSON(client.OpenRead(uri)); 
    }


    private void ParseJSON(Stream stream)
    {
        if (stream == null)
            return;

        StreamReader reader = new StreamReader(stream);
        JObject searchResult = JObject.Parse(reader.ReadLine());

        string x= searchResult["SearchResults"][0]["SEARCHVAL"]["X"].ToString();
        string y= searchResult["SearchResults"][0]["SEARCHVAL"]["Y"].ToString();

        // use data
        ...

and I’m getting a null exception on string lat = searchresult.... Any clue where I went wrong on using JSON.NET?

  • 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-26T18:48:46+00:00Added an answer on May 26, 2026 at 6:48 pm

    Here’s the working solution using JSON.NET:

    Getting the json:

            WebClient client = new WebClient();
            using (StreamReader reader = new StreamReader(client.OpenRead(uri)))
            {
                json = reader.ReadToEnd();
            }
    

    Parsing the stream as JObject:

            JObject searchResult = JObject.Parse(json);
    
            string lat = searchResult["SearchResults"][1]["X"].ToString().Replace("\"","");
            string lon = searchResult["SearchResults"][1]["Y"].ToString().Replace("\"","");
    

    the .Replace() can be disregarded if there are no unnecessary characters included on the parsed string. I was using Json.NET 3.5 so you’ll probably won’t need to do this in the most updated release.

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

Sidebar

Related Questions

I have a feeling that I already know the answer to this one, but
I am sorry I have already asked this question on Superuser, but nobody answers
I am using this question/answer as source code for my current need. It works
I am sure this is a pretty easy answer, but I have been pulling
i already have json object..like this, updates={ mainUpdates:[{id:'1', inner:[{mid:'11',sub_domain:'a'},{mid:'12',sub_domain:'b'}]}, {id:'2', inner:[{mid:'21', sub_domain:'c'},{mid:'22',sub_domain:'d'}]} ], msgCount:'2'
The question has two parts, one of which I already have the answer for.
I have a feeling I already know the answer people are going to give,
I already have code which lazy loads scripts on request. My issue now is
I guess many people already read this article: Using your own SQLite database in
i have code like this: loading js files dynamically via another js file? but

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.