---
title: "Converting JSON to GridView"  
description: "Converting JSON to GridView"  
author: "Anonymous User"  
published: 2014-12-26  
updated: 2014-12-26  
canonical: https://www.mindstick.com/forum/12817/converting-json-to-gridview  
category: ".net"  
tags: [".net", "json", "gridview"]  
reading_time: 2 minutes  

---

# Converting JSON to GridView

I set up a test DreamFactory [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) and I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to [transform](https://www.mindstick.com/interview/511/what-are-the-steps-to-transform-xml-into-html-using-xsl) the [results](https://yourviews.mindstick.com/story/4497/usage-of-baking-soda-magical-results) from JSON to a [DataTable](https://www.mindstick.com/blog/195/datatable-in-ado-dot-net) so I can display a GridView. I've tried several things with no [success](https://www.mindstick.com/articles/12957/best-tips-to-make-your-ghostwriting-experience-a-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](https://www.mindstick.com/articles/13060/runny-nose-remedy-methods-that-work-best) but I [am getting](https://www.mindstick.com/forum/34179/i-am-getting-error-while-assigning-the-data-to-the-array-list) the following error most of the time:\
Unexpected JSON token when [reading](https://www.mindstick.com/articles/126273/books-commonly-found-on-college-reading-lists) 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](https://www.mindstick.com/articles/23258/choose-your-business-structure-wisely)\

```
{"record":[{"StatusID":1, "Identifier":"DQRJO1Q0IQRS", "Status":"WaitList","StatusDate":"2014-11-15","WorkedBy":"None","ContactedOn":"2014-11-15T14:21:55.623","Email":"email}]}
```

## Replies

### Reply by Tom Cruser

Your json isn't a DataTable. All you need is to deserialize to\

```
var root = JsonConvert.DeserializeObject<RootObject>(result);public class Record{    public int StatusID { get; set; }    public string Identifier { get; set; }    public string Status { get; set; }    public string StatusDate { get; set; }    public string WorkedBy { get; set; }    public string ContactedOn { get; set; }    public string Email { get; set; }}public class RootObject{    public List<Record> Record { get; set; }}
```


---

Original Source: https://www.mindstick.com/forum/12817/converting-json-to-gridview

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
