使用 Scala 的 YAML [英] Working with YAML for Scala

查看:50
本文介绍了使用 Scala 的 YAML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为此https://github.com/daltontf/scala-yaml找到了一个库,但似乎就像没有多少开发人员使用它一样,它已经过时了.如果链接没有失效,它也可能是这个 http://www.lag.net/configgy/.>

我想知道,在 Scala 中使用 YAML 的最流行的或事实上的库是什么?

解决方案

SnakeYAML质量,积极维护 Java 的 YAML 解析器/渲染器.您当然可以在 Scala 中使用它.

如果您已经在使用 circe,您可能会对 circe-yaml 使用 SnakeYAML 解析 YAML 文件,然后将结果转换为 circe AST.

我希望看到一个可以将 JSON 或 YAML(或其他任何东西——可插拔)解析为通用 AST,然后使用类型类构造 Scala 对象的库.有几个 JSON 库是这样工作的(当然也可以为使用相同类型类的对象呈现 JSON),但我不知道 YAML 有这样的工具.


PS:SnakeYAML 似乎也有一些看似废弃的包装器,即 HelicalYAMLyaml4s

I found one library for this https://github.com/daltontf/scala-yaml, but it seems like not many developers use it and it's pretty outdated. It also might be this http://www.lag.net/configgy/ if the link wasn't dead.

I wonder, what is the most popular or de-facto library for working with YAML in Scala?

解决方案

SnakeYAML is a high-quality, actively maintained YAML parser/renderer for Java. You can of course use it from Scala.

If you're already working with circe, you might be interested in circe-yaml which uses SnakeYAML to parse a YAML file and then converts the result to a circe AST.

I would love to see a library that could parse either JSON or YAML (or whatever -- pluggable) to a common AST and then construct Scala objects using typeclasses. Several JSON libraries work like that (and of course can also render JSON for objects using the same typeclasses), but I don't know of such a facility for YAML.


PS: There also appear to be a number of seemingly abandoned wrappers for SnakeYAML, namely HelicalYAML and yaml4s

这篇关于使用 Scala 的 YAML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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