As the header says.
正如标题所说。
In general I like YAML more than JSON these days. I implemented a RESTful WS PoC back in teh day using JSON. I was wondering if I can instead use YAML or not.
总的来说,我最近比JSON更喜欢YAML。我使用JSON在第几天实现了RESTful WS PoC。我想知道我是否可以改用YAML。
E.g. are there enough tools/libraries/support for doing that? Or would I end up doing quite a bit of mundane/tedious coding which I would've avoided if I were using JSON instead?
例如。有没有足够的工具/库/支持这样做?或者我最终会做一些平凡/乏味的编码,如果我使用JSON,我会避免这种编码?
Also as I understood from WWW: REST doesn't restrict one from using YAML as the payload, is that correct?
另外正如我从WWW所理解的那样:REST并不限制使用YAML作为有效载荷,这是正确的吗?
Thanks!
谢谢!
1 个解决方案
#1
5
Yes, if it's a goal that the data be especially readable by humans. REST itself isn't focused on protocols/formats so much as patterns.
是的,如果这是一个人类特别可读的数据的目标。 REST本身并不像模式那样专注于协议/格式。
There's not a lot to gain here for webservices however, which typically represent app to app communication. Computers don't care, and JSON can be pretty-printed to improve legibility somewhat.
然而,这里的网络服务并没有太大的收获,这通常代表应用程序与应用程序之间的通信。计算机并不关心,JSON可以打印得漂亮,以提高可读性。
YAML is well supported by mainstream languages, though not always included in standard libraries as JSON typically is. So you'll probably be looking at an additional library dependency. Also, if the client is a browser, parsing will be slower, as you'll have to use a non-native external lib such as described here using: JavaScript YAML Parser . Make sure it gets compressed in transit or the extra indentation spaces will expand the size of the data.
YAML得到了主流语言的很好支持,但并不总是像JSON那样总是包含在标准库中。所以你可能会看到一个额外的库依赖项。此外,如果客户端是浏览器,则解析速度会变慢,因为您必须使用非本机外部库,如此处所述:JavaScript YAML Parser。确保它在传输过程中被压缩,或者额外的缩进空间将扩展数据的大小。
Also, YAML has a lot of esoteric and downright potentially dangerous features. Whenever I'm using it I use the "safe" parser, and deactivate many if not most of its features besides data structures.
此外,YAML有很多深奥和彻头彻尾的潜在危险特征。每当我使用它时,我都会使用“安全”解析器,并且除了数据结构之外,还会停用许多(如果不是大多数)功能。
I could imagine some utility as a debug parameter however, perhaps url.yaml
or …?fmt=yaml
to assist during development. But, otherwise not much gain for all the trouble.
我可以想象一些实用程序作为调试参数,但也许url.yaml或...?fmt = yaml在开发过程中提供帮助。但是,否则所有麻烦都没有太大的收获。
#1
5
Yes, if it's a goal that the data be especially readable by humans. REST itself isn't focused on protocols/formats so much as patterns.
是的,如果这是一个人类特别可读的数据的目标。 REST本身并不像模式那样专注于协议/格式。
There's not a lot to gain here for webservices however, which typically represent app to app communication. Computers don't care, and JSON can be pretty-printed to improve legibility somewhat.
然而,这里的网络服务并没有太大的收获,这通常代表应用程序与应用程序之间的通信。计算机并不关心,JSON可以打印得漂亮,以提高可读性。
YAML is well supported by mainstream languages, though not always included in standard libraries as JSON typically is. So you'll probably be looking at an additional library dependency. Also, if the client is a browser, parsing will be slower, as you'll have to use a non-native external lib such as described here using: JavaScript YAML Parser . Make sure it gets compressed in transit or the extra indentation spaces will expand the size of the data.
YAML得到了主流语言的很好支持,但并不总是像JSON那样总是包含在标准库中。所以你可能会看到一个额外的库依赖项。此外,如果客户端是浏览器,则解析速度会变慢,因为您必须使用非本机外部库,如此处所述:JavaScript YAML Parser。确保它在传输过程中被压缩,或者额外的缩进空间将扩展数据的大小。
Also, YAML has a lot of esoteric and downright potentially dangerous features. Whenever I'm using it I use the "safe" parser, and deactivate many if not most of its features besides data structures.
此外,YAML有很多深奥和彻头彻尾的潜在危险特征。每当我使用它时,我都会使用“安全”解析器,并且除了数据结构之外,还会停用许多(如果不是大多数)功能。
I could imagine some utility as a debug parameter however, perhaps url.yaml
or …?fmt=yaml
to assist during development. But, otherwise not much gain for all the trouble.
我可以想象一些实用程序作为调试参数,但也许url.yaml或...?fmt = yaml在开发过程中提供帮助。但是,否则所有麻烦都没有太大的收获。