shampoo.yaml
Members list
Type members
Classlikes
Provides YAML utilities.
Provides YAML utilities.
import scala.language.implicitConversions
import shampoo.yaml.{ *, given }
// Create YAML mapping
val user = Yaml.map("id" -> 1000, "name" -> "lupita")
// Create YAML sequence
val info = Yaml.seq(user, "/home/lupita", 1024)
// Load YAML
val root = Yaml.load("{ id: 0, name: root }")
case class User(id: Int, name: String)
given userRepresenter: YamlRepresenter[User] =
user => Yaml.map("id" -> user.id, "name" -> user.name)
// Represent value to YAML
val nobody = Yaml.toYaml(User(65534, "nobody"))
// Dump YAML to stdout
Yaml.dump(nobody, System.out)
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Yaml.type
Defines YAML boolean.
Provides YAML boolean constructor.
Provides YAML boolean constructor.
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
YamlBoolean.type
Defines YAML collection.
Defines YAML collection.
Attributes
- Supertypes
- Known subtypes
Assumes either YAML mapping or YAML sequence.
Assumes either YAML mapping or YAML sequence.
Attributes
- See also
- Note
-
A collection facade is created by conversion only.
- Supertypes
-
trait YamlSequencetrait YamlMappingtrait YamlCollectiontrait YamlNodeclass Objecttrait Matchableclass AnyShow all
Defines YAML constructor.
Defines YAML constructor.
import scala.language.implicitConversions
import shampoo.yaml.{ *, given }
case class User(id: Int, name: String)
// Define how to construct User from YAML
given YamlConstructor[User] =
yaml => User(yaml("id"), yaml("name"))
val yaml = Yaml.load("{ id: 1000, name: lupita }")
// Construct and verify
val user = yaml.as[User]
assert(user.id == 1000)
assert(user.name == "lupita")
Attributes
- See also
- Supertypes
-
class Objecttrait Matchableclass Any
Defines YAML exception.
Defines YAML exception.
Value parameters
- cause
-
underlying cause
- message
-
detail message
Attributes
- Constructor
-
Creates exception with message and cause.
- Supertypes
-
class RuntimeExceptionclass Exceptionclass Throwabletrait Serializableclass Objecttrait Matchableclass AnyShow all
Defines YAML mapping.
Defines YAML mapping builder.
Defines YAML mapping builder.
import scala.language.implicitConversions
import shampoo.yaml.{ *, given }
val user = YamlMappingBuilder()
.add("id", 1000)
.add("name", "lupita")
.add("groups", Set("lupita", "sudoer"))
.toYamlMapping()
assert { user("id").as[Int] == 1000 }
assert { user("name").as[String] == "lupita" }
assert { user("groups").as[Set[String]] == Set("lupita", "sudoer") }
Attributes
- See also
- Supertypes
-
class Objecttrait Matchableclass Any
Defines YAML node.
Defines YAML node.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait YamlCollectiontrait YamlMappingclass YamlCollectionFacadetrait YamlSequencetrait YamlScalartrait YamlBooleanobject YamlNull.typetrait YamlNumbertrait YamlStringtrait YamlTimestampShow all
Defines YAML null.
Defines YAML null.
Attributes
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalstrait YamlScalartrait YamlNodeclass Objecttrait Matchableclass AnyShow all
- Self type
-
YamlNull.type
Defines YAML number.
Provides YAML number constructor.
Provides YAML number constructor.
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
YamlNumber.type
Defines YAML representer.
Defines YAML representer.
import scala.language.implicitConversions
import shampoo.yaml.{ *, given }
case class User(id: Int, name: String, groups: Seq[String])
// Define how to represent YAML from User
given YamlRepresenter[User] =
user => Yaml.map("id" -> user.id, "name" -> user.name)
val lupita = User(1000, "lupita")
// Represent and verify
val yaml = Yaml.toYaml(lupita)
assert(yaml.getInt("id") == 1000)
assert(yaml.getString("name") == "lupita")
Attributes
- See also
- Supertypes
-
class Objecttrait Matchableclass Any
Defines YAML scalar.
Defines YAML scalar.
Attributes
- Supertypes
- Known subtypes
Defines YAML sequence.
Defines YAML sequence builder.
Defines YAML sequence builder.
import scala.language.implicitConversions
import shampoo.yaml.{ *, given }
val user = YamlSequenceBuilder()
.add(1000)
.add("lupita")
.add(Set("lupita", "sudoer"))
.toYamlSequence()
assert { user(0).as[Int] == 1000 }
assert { user(1).as[String] == "lupita" }
assert { user(2).as[Set[String]] == Set("lupita", "sudoer") }
Attributes
- See also
- Supertypes
-
class Objecttrait Matchableclass Any
Defines YAML string.
Provides YAML string constructor.
Provides YAML string constructor.
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
YamlString.type
Defines YAML timestamp.
Provides YAML timestamp constructors.
Provides YAML timestamp constructors.
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
YamlTimestamp.type
Givens
Givens
Represents Array
to YamlSequence
.
Represents Array
to YamlSequence
.
Attributes
Constructs BigDecimal
from YamlNumber
.
Constructs BigDecimal
from YamlNumber
.
Attributes
Represents BigDecimal
to YamlNumber
.
Represents BigDecimal
to YamlNumber
.
Attributes
Constructs BigInt
from YamlNumber
.
Constructs BigInt
from YamlNumber
.
Attributes
Represents BigInt
to YamlNumber
.
Represents BigInt
to YamlNumber
.
Attributes
Constructs Boolean
from YamlBoolean
.
Constructs Boolean
from YamlBoolean
.
Attributes
Represents Boolean
to YamlBoolean
.
Represents Boolean
to YamlBoolean
.
Attributes
Constructs collection from YamlSequence
.
Constructs collection from YamlSequence
.
Attributes
Constructs Double
from YamlNumber
.
Constructs Double
from YamlNumber
.
Attributes
Represents Double
to YamlNumber
.
Represents Double
to YamlNumber
.
Attributes
Constructs Either
from YamlNode
.
Constructs Either
from YamlNode
.
Attributes
Represents Either
to YamlNode
.
Represents Either
to YamlNode
.
Attributes
Represents Failure
to YamlNull
.
Represents Failure
to YamlNull
.
Attributes
Constructs Float
from YamlNumber
.
Constructs Float
from YamlNumber
.
Attributes
Represents Float
to YamlNumber
.
Represents Float
to YamlNumber
.
Attributes
Constructs Instant
from YamlTimestamp
.
Constructs Instant
from YamlTimestamp
.
Attributes
Represents Instant
to YamlTimestamp
.
Represents Instant
to YamlTimestamp
.
Attributes
Constructs Int
from YamlNumber
.
Constructs Int
from YamlNumber
.
Attributes
Represents Int
to YamlNumber
.
Represents Int
to YamlNumber
.
Attributes
Represents Iterable
to YamlSequence
.
Represents Iterable
to YamlSequence
.
Attributes
Represents Left
to YamlNode
.
Represents Left
to YamlNode
.
Attributes
Constructs LocalDate
from YamlTimestamp
.
Constructs LocalDate
from YamlTimestamp
.
Attributes
Represents LocalDate
to YamlTimestamp
.
Represents LocalDate
to YamlTimestamp
.
Attributes
Constructs LocalDateTime
from YamlTimestamp
.
Constructs LocalDateTime
from YamlTimestamp
.
Attributes
Represents LocalDateTime
to YamlTimestamp
.
Represents LocalDateTime
to YamlTimestamp
.
Attributes
Constructs Long
from YamlNumber
.
Constructs Long
from YamlNumber
.
Attributes
Represents Long
to YamlNumber
.
Represents Long
to YamlNumber
.
Attributes
Converts YamlNode
to Map
.
Converts YamlNode
to Map
.
Attributes
Represents Map
to YamlMapping
.
Represents Map
to YamlMapping
.
Attributes
Represents None
to YamlNull
.
Represents None
to YamlNull
.
Attributes
Constructs OffsetDateTime
from YamlTimestamp
.
Constructs OffsetDateTime
from YamlTimestamp
.
Attributes
Represents OffsetDateTime
to YamlTimestamp
.
Represents OffsetDateTime
to YamlTimestamp
.
Attributes
Constructs Option
from YamlNode
.
Constructs Option
from YamlNode
.
Attributes
Represents Some
to YamlNode
or returns YamlNull
if None
.
Represents Some
to YamlNode
or returns YamlNull
if None
.
Attributes
Represents Right
to YamlNode
.
Represents Right
to YamlNode
.
Attributes
Constructs String
from YamlString
.
Constructs String
from YamlString
.
Attributes
Represents String
to YamlString
.
Represents String
to YamlString
.
Attributes
Constructs Try
from YamlNode
.
Constructs Try
from YamlNode
.
Attributes
Represents Success
to YamlNode
or returns YamlNull
if Failure
.
Represents Success
to YamlNode
or returns YamlNull
if Failure
.
Attributes
Casts YamlNode
to YamlBoolean
.
Casts YamlNode
to YamlBoolean
.
Attributes
Applies conversion using YamlConstructor
.
Applies conversion using YamlConstructor
.
Attributes
Returns YamlNode
as is.
Returns YamlNode
as is.
This constructor is required to perform actions such as the following:
import scala.language.implicitConversions
import shampoo.yaml.{ Yaml, YamlNode, given }
val yaml = Yaml.map("values" -> Yaml.seq("abc", 123, true))
// Requires yamlNodeConstructor
val list = yaml("values").as[List[YamlNode]]
Attributes
Casts YamlNode
to YamlNull
.
Casts YamlNode
to YamlNull
.
Attributes
Casts YamlNode
to YamlNumber
.
Casts YamlNode
to YamlNumber
.
Attributes
Casts YamlNode
to YamlMapping
.
Casts YamlNode
to YamlMapping
.
Attributes
Applies conversion using YamlRepresenter
.
Applies conversion using YamlRepresenter
.
Attributes
Casts YamlNode
to YamlSequence
.
Casts YamlNode
to YamlSequence
.
Attributes
Casts YamlNode
to YamlString
.
Casts YamlNode
to YamlString
.
Attributes
Converts YamlNode
to YamlCollectionFacade
.
Converts YamlNode
to YamlCollectionFacade
.
Attributes
Extensions
Extensions
Gets value in YAML mapping.
Gets value in YAML mapping.
Value parameters
- key
-
mapping key
Attributes
- Throws
-
ClassCastException
if not YamlMapping
Gets value in YAML sequence.
Gets value in YAML sequence.
Value parameters
- index
-
sequence index
Attributes
- Throws
-
ClassCastException
if not YamlSequence
Collects values with given mapping key while traversing nested mappings and sequences.
Collects values with given mapping key while traversing nested mappings and sequences.
import shampoo.yaml.{ Yaml, \\, given }
val yaml = Yaml.load("""
node:
name: localhost
users:
- id: 0
name: root
- id: 1000
name: lupita
""")
val names = (yaml \\ "name").map(_.as[String])
assert { names == Seq("localhost", "root", "lupita") }
Value parameters
- key
-
mappings key