Last active
December 9, 2019 18:48
-
-
Save heath/297e0ae4b1b603221a282a9a1d19ac0f to your computer and use it in GitHub Desktop.
example of decoding a MisoString into an Either String Aeson.Value
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
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Miso.String | |
import qualified Data.Aeson as Aeson | |
import qualified Data.Text.Lazy.Encoding as E | |
import qualified Data.Text.Lazy as TL | |
main :: IO () | |
main = do | |
let myMisoString = "{\"a\": 1}" :: MisoString | |
myAesonValue = | |
Aeson.eitherDecode (E.encodeUtf8 $ TL.fromStrict myMisoString) | |
print (myAesonValue :: Either String Aeson.Value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment