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

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

问题描述

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

我想知道,在 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天全站免登陆