0

Can some one help me in finding out this?

I wanted to read the below timestamp in the resultant JSON response (in BOLD). I want to copy the value of t (first and second time in the response).

{"op":"&","c":[{"type":"completion","cm":1254,"e":1},{"type":"completion","cm":27869,"e":1},{"type":"date","d":">=","t":**1426767000**},{"type":"date","d":"<","t":**1458389400**}],"showc":[true,true,true,true]}

Here is my program code:

currentnode = matchquiz.SelectNodes("KEY[@name='availability']/VALUE")[0];
if (currentnode != null)
{
    mdle_availablefrom = currentnode.FirstChild.Value;
    if (mdle_availablefrom != "0")
    {
          //System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
          //dtDateTime = dtDateTime.AddSeconds(double.Parse(mdle_availablefrom)).ToLocalTime();
          //mdle_availablefrom = dtDateTime.ToString();
    }
    else
          mdle_availablefrom = string.Empty;
}

I have saved the response in "mdle_availablefrom", Now i want toread the values of both the t's in two different variables in the if block. Value of t(Time) is in double.

2
  • What is matchquiz, an XmlDocument? Something is missing here, how can JSON string on top relates to the codes below it, Can you pl be clear?? Commented Apr 6, 2015 at 7:51
  • hi @har07. matchquiz is just a xml variable initialized, XmlNode matchquiz = module.ParentNode; i have the JSON response in mdle_availablefrom and want to parse the json Commented Apr 6, 2015 at 9:02

1 Answer 1

1

Why don't you create an object model that represents the JSON you can then use it as an object set and it's far more readable to other programmers using the code.

I recommend NewtonJSON :)

Deserialize by var model = JsonConvert.DeserializeObject<RootObject>(json); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.