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.
-
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