What is the difference between DataContractSerializer and DataContractJsonSerializer? There is any difference in class, use and speed at all?
-
-1: You really try to read MSDN description before asking question. I.e. speed is rarely concern when operations are significantly different... – Alexei Levenkov Sep 27 '13 at 00:50
-
Sure MSDN help a lot, unfortunately on this one, beside saying one is for JSON and another is for XML nothing more said about it... really poor documentation. @AlexeiLevenkov – Guilherme.Morais Sep 27 '13 at 01:00
-
Well this question is the top hit on google now, so I'm glad that it got an answer. – NotAGenie Apr 13 '17 at 03:49
2 Answers
straight from the MSDN
DataContractSerializer---Serializes and deserializes an instance of a type into an XML stream or document using a supplied data contract. This class cannot be inherited.
DataContractJsonSerializer---Serializes objects to the JavaScript Object Notation (JSON)
and deserializes JSON data to objects. This class cannot be inherited.
in speed I think json might be faster

- 13,513
- 3
- 35
- 52
Apart from the obvious serialization format differences, there are also limitations as to what the respective serializer is capable of handling.
In particular, DataContractSerializer
is capable of handling circular references by setting the IsReference
property of the DataContractAttribute
constructor to true
. DataContractJsonSerializer
is not able to handle this scenario since there is no standardized representation of references in JSON (according to the WriteObject
error message).

- 1
- 1

- 15,837
- 8
- 56
- 114