Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which format should I choose to request API in C# - JSON or XML

Tags:

json

rest

c#

xml

api

I'm requesting data from a REST API in C#. The API offers me the same data in a JSON and XML format.

For which one should I go? It's clear which one I would choose in JavaScript. But what in C#? Are there any performance benefits to help me choose one over the other in C# or any good-practice reasons?

Thanks in advance!

like image 408
Martin Buberl Avatar asked Dec 28 '22 02:12

Martin Buberl


1 Answers

Personally I would try both, measure the performance, compare and choose the one that's faster. From your application logic perspective this shouldn't really matter as it will be manipulating objects (not XML, nor JSON). The conversion of the XML/JSON to objects should be abstracted away into a repository which you could, within a blink of an eye, substitute with another implementation if you feel that the one you have chosen initially is slow or it doesn't work for you.

like image 199
Darin Dimitrov Avatar answered Feb 05 '23 08:02

Darin Dimitrov