diff options
Diffstat (limited to 'doc-tool/src/dotty/tools/dottydoc/staticsite/Yaml.scala')
-rw-r--r-- | doc-tool/src/dotty/tools/dottydoc/staticsite/Yaml.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/doc-tool/src/dotty/tools/dottydoc/staticsite/Yaml.scala b/doc-tool/src/dotty/tools/dottydoc/staticsite/Yaml.scala new file mode 100644 index 000000000..07bc27562 --- /dev/null +++ b/doc-tool/src/dotty/tools/dottydoc/staticsite/Yaml.scala @@ -0,0 +1,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) + } +} |