Created
March 7, 2015 10:16
-
-
Save seanparsons/71d9fae9e0733c42d341 to your computer and use it in GitHub Desktop.
Decoding an enum.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit val myEnumDecodeJson: DecodeJson[MyEnum] = DecodeJson{hCursor => | |
hCursor.focus match { | |
case `myEnumValue1Json` => DecodeResult.ok(MyEnumValue1) | |
case `myEnumValue2Json` => DecodeResult.ok(MyEnumValue2) | |
case _ => DecodeResult.fail("Expected MyEnum.", hCursor.history) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment