forum

Home / DeveloperSection / Forums / Converting JSON to GridView

Converting JSON to GridView

Anonymous User 6965 26-Dec-2014
 I set up a test DreamFactory server and I am trying to transform the results from JSON to a DataTable so I can display a GridView. I've tried several things with no success, this is my current code:

 var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                result = streamReader.ReadToEnd();
                dynamic d = JObject.Parse(result);
            }
            object obj = JsonConvert.DeserializeObject(result); 
            var table = JsonConvert.DeserializeObject<DataTable>(result); <--ERROR
            return table;
I've tried several methods but I am getting the following error most of the time:

Unexpected JSON token when reading DataTable. Expected StartArray, got StartObject. Path '', line 1, position 1.

It can deserialize fine as the object shows me the full deserialized JSON with no problems. Anything I can do?

EDIT: JSON Structure

{"record":[{"StatusID":1, "Identifier":"DQRJO1Q0IQRS",
 "Status":"WaitList",
"StatusDate":"2014-11-15",
"WorkedBy":"None",
"ContactedOn":"2014-11-15T14:21:55.623",
"Email":"email}]}

Updated on 26-Dec-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By