Last active
August 9, 2017 02:47
-
-
Save rahulmutt/ef2cb4666221221589340ef4187873e1 to your computer and use it in GitHub Desktop.
Code for Eta <-> Scala blog post
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
module Example.Transform where | |
import Java | |
import Control.Lens | |
import Data.Aeson | |
import Data.Aeson.Lens | |
import Data.Text (Text) | |
import qualified Data.Text as T | |
fixJson :: JString -> JString | |
fixJson = toJava . transform . fromJava | |
where transform :: Text -> Text | |
transform json = json & (key "first_name" . _String) %~ T.toUpper | |
& (key "last_name" . _String) %~ T.toUpper | |
& (key "events" . key "clicks" . _Integral) %~ (+ 50) | |
foreign export java "@static eta.example.Transform.fixJson" | |
fixJson :: JString -> JString |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment