aboutsummaryrefslogtreecommitdiff
path: root/doc-tool/src/dotty/tools/dottydoc/staticsite/Yaml.scala
blob: 07bc2756200ca00c3e939b5a2ee7373d5f37cdcf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package dotty.tools
package dottydoc
package staticsite

import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.core.`type`.TypeReference

object Yaml {
  import scala.collection.JavaConverters._
  import java.util.HashMap
  import java.io.ByteArrayInputStream

  def apply(input: String): HashMap[String, AnyRef] = {
    val is = new ByteArrayInputStream(input.getBytes("UTF-8"))
    val mapper = new ObjectMapper(new YAMLFactory())

    val typeRef: TypeReference[HashMap[String, AnyRef]] =
      new TypeReference[HashMap[String, AnyRef]] {}

    mapper.readValue(is, typeRef)
  }
}