Discriminated
alloy.Discriminated
object Discriminated extends Newtype[String]
Discriminated unions contain the information about which branch of a union is encoded inside of the object itself. The following union: structure One { a: Int } structure Two { b: String } union Test { one: One two: Two } would normally be encoded in JSON as: { "one": { "a": 123 } } when annotated with ``@discriminated("type")
, it will instead be encoded as: { "a": 123, "type": "one" } This is more efficient than using an untagged encoding, but less efficient than using the default tagged union encoding. Therefore, it should only be used when necessary. Tagged union encodings should be used wherever possible.
Attributes
- Graph
-
- Supertypes
- Self type
-
Discriminated.type
Members list
In this article