Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

SnakeYAML

moultingyaml: Scala wrapper for SnakeYAML

Comment

If the input YAML doc has multiple formats, you can first load it as an Object and then use Object.isInstanceOf to check its type and use Object.asInstanceOf[SomeType] to cast it to the right type.

Loading...
Loading...
import scala.collection.JavaConverters._
import org.yaml.snakeyaml.Yaml
import scala.collection.JavaConverters._
Yaml:1842984473
- Hesperiidae - Papilionidae - Apatelodidae - Epiplemidae
[Hesperiidae, Papilionidae, Apatelodidae, Epiplemidae]
true
false
[Hesperiidae, Papilionidae, Apatelodidae, Epiplemidae]
[Hesperiidae, Papilionidae, Apatelodidae, Epiplemidae]
java.lang.ClassCastException: java.util.ArrayList cannot be cast to scala.collection.Seq
  ... 48 elided
[Hesperiidae, Papilionidae, Apatelodidae, Epiplemidae]
[Hesperiidae, Papilionidae, Apatelodidae, Epiplemidae]
aa: - x - y bb: z
Loading...

Read YAML From a File

The following way of reading from a file is problematic ...

Yaml:923704732
Loading...

Cast to Map

13.0775