如何使用SnakeYaml低级API解析YAML,类似于getAsInt?

huangapple go评论72阅读模式
英文:

How to parse YAML with SnakeYaml low-level API like getAsInt?

问题

SnakeYaml文档提供了如何将YAML反序列化为Java类的示例。

我正在寻找类似于GSON的getAsInt的简单低级API,SnakeYaml支持吗?

英文:

The SnakeYaml docs provide examples how to de-serialize YAML into Java Class.

I'm looking for simple low-level API that's similar to GSON getAsInt, does SnakeYaml support that?

答案1

得分: 1

如果您在没有指定表示类型的情况下使用SnakeYaml的load方法来加载一个Yaml对象,您将得到一个由ListMap集合组成的数据结构,其中"values"表示为StringInteger等的实例。

听起来这很接近您所寻找的内容。

英文:

If you use SnakeYaml's load method on a Yaml object created without specifying a representation type, you will get a data structure composed of List and Map collections, with the "values" represented as instances of String, Integer and so on.

It sounds like that is close to what you are looking for.

huangapple
  • 本文由 发表于 2020年8月9日 12:46:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/63322540.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定