6

I want to serialize object in c# and learn that we can do this both JsonSerializer and JsonConvert. I know about documentation knowledges about these.

But I want to know which is better to use for serialization objects? JsonSerializer or JsonConvert?

vaqifrv
  • 754
  • 1
  • 6
  • 20
  • 2
    And your question is...? Can you provide some sort of context? Completely unclear what you're asking... – Geoff James Aug 12 '16 at 10:18
  • 1
    now you understand that question? – Valeh Mikayilzadeh Aug 12 '16 at 10:31
  • 1
    This question is unfortunately off-topic due to the site policy of not allowing questions which ask for recommendations. The term "better" is subjective and prone to being opinion-based, something which is also off-topic. Without a much clearer question both the question and potential answers is going to be off-topic for this site. If you can reword it it may be on-topic. A tip would be to simply test both, or at least one of them and if you encounter something that doesn't work come back and ask about that. – Lasse V. Karlsen Aug 12 '16 at 10:36

1 Answers1

4

JsonConvert from JSON.net is reportedly better for performance. I actually use it myself and find it very easy to use and works well with attributes in classes. In terms of memory usages it was good for us. The application I work is able to handle around 3500 to 4000 requests including 3 deserialization, 2 http service calls to retrieve data and, one serialization and one service call to push data.. So, in terms of performance it was a great choice.

http://www.newtonsoft.com/json/help/html/performance.htm (I know, a bit biased, but still) nuget: https://www.nuget.org/packages/newtonsoft.json/

Arsman Ahmad
  • 2,000
  • 1
  • 26
  • 34
  • 1
    I've also got some "circular reference" errors when using JsonSerializer with some structs, while JsonConvert handles them successfully without extra effort. – fibriZo raZiel Oct 21 '19 at 11:11