我应该选择哪一种格式,要求在C#API - JSON或XML [英] Which format should I choose to request API in C# - JSON or XML

查看:191
本文介绍了我应该选择哪一种格式,要求在C#API - JSON或XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中的REST API请求数据。该API提供给我一个JSON和XML格式的数据相同。

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

有关哪一个我应该去吗?这是明确哪一个我会在JavaScript中进行选择。 但是在C#是什么?是否有任何性能优势,帮助我选择了另一种在C#或任何良好做法的理由?

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?

在此先感谢!

推荐答案

我个人尝试两种,测量性能,比较和选择一个速度更快。从你的应用程序逻辑角度来看,这应该不是真正的问题,因为它会被操纵的对象(不是XML,JSON也没有)。在XML / JSON对象的转换应该抽象掉在其中,你可以,眼睛一眨不眨内,代替用其他实现,如果你觉得你已经最初选择之一是缓慢的一个仓库里或者它不工作你。

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.

这篇关于我应该选择哪一种格式,要求在C#API - JSON或XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆