Support export of query results to JSON
I want to create a JSON file for use as part of a simple web prototyping exercise. LinqPAD is perfect for accessing the data from my DB in just the shape I need, however I cannot get it out as JSON very easily.
I don't really care what the schema is, because I can adapt my JavaScript to work with whatever is returned.
![](https://secure.gravatar.com/avatar/58aa54a781da5d861abbcfc5edc94e7d?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
-
Tom commented
Add a reference to Json.net, and write an extension method .ToJson() that will call JsonConvert.DeserializeObject<T>. Then you can take any set of results and simply call .ToJson on them.
-
Anonymous commented
This is useful in debugging real applications, too.
-
Drew Noakes commented
I created a topic for this on Stack Overflow as well: http://stackoverflow.com/q/17601302/24874