dcsimg
Results 1 to 2 of 2

Thread: How to read JSON passed to an asp.net page?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Question How to read JSON passed to an asp.net page?

    Hello,

    I have read about desearlizing a json file into class fields which I understand. But what I cannot find in a tutorial is how to read in the json data. Everyone just adds the data to a variable and uses it. I will be passing in a json file from a mobile app. I know I should use a web service but for now I want to use an asp.net ASPX page to do this. I will be using the newton king json control.

    Can someone show me how to read in the json to a variable? Hopefully I will be set then!

    Thanks,
    Warren

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Re: How to read JSON passed to an asp.net page?

    I see here how to read it from a file but how about being passed to the URL?

    Code:
    JObject o1 = JObject.Parse(File.ReadAllText(@"c:\videogames.json"));
    
    // read JSON directly from a file
    using (StreamReader file = File.OpenText(@"c:\videogames.json"))
    using (JsonTextReader reader = new JsonTextReader(file))
    {
      JObject o2 = (JObject) JToken.ReadFrom(reader);
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width