A
A
alex995052015-10-22 00:03:07
ASP.NET
alex99505, 2015-10-22 00:03:07

How to return a DataTable in json and xml format in response to a Get request?

I receive the table from a DB.
How to format it as a response in the form of json and xml?
Will these lines be enough if the $format variable is specified in the GET request?:

GlobalConfiguration.Configuration.Formatters.JsonFormatter.AddQueryStringMapping("$format", "json", "application/json");
GlobalConfiguration.Configuration.Formatters.XmlFormatter.AddQueryStringMapping("$format", "xml", "application/xml");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2015-10-29
@kttotto

I would prefer json. Recently, the majority is inclined to use it, after all, it is more familiar to JS. Even Microsoft, in some of their products, are switching from xml to json.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question