Is there a tool out there that can quickly and simply generate a DataContract from either XML or JSON? Doing it manually can be a real pain.
closed as off topic by Thomas Owens♦ Oct 24 '12 at 14:12
Questions on Programmers Stack Exchange are expected to relate to software development within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.
To have a generator you need well defined structure. Both JSON and XML are just a way to describe data of any structure. You can probably write the generator to create class for the given XML or JSON snippet but it doesn't mean that the next snippet generated by the same source will have the same structure. For example your initial snippet can miss some optional data structures which will be included in the next snippet. Because of that generic generator doesn't make too much sense.
.NET offers tool to generate class from XML but the XML must be described by XSD - it clearly communicates valid structure of exchanged XML. The tool is called XSD.exe. In the same way you can create DataContracts from XSD by svcutil.exe with /dconly.
While you mentioned needing to do this from XML/JSON .. here is a handy tool that will let you generate them from classes/entities, if you have them: DTO Generator.