Skip to content

Instantly share code, notes, and snippets.

@rahulmutt
Last active August 9, 2017 02:47
Show Gist options
  • Save rahulmutt/ef2cb4666221221589340ef4187873e1 to your computer and use it in GitHub Desktop.
Save rahulmutt/ef2cb4666221221589340ef4187873e1 to your computer and use it in GitHub Desktop.
Code for Eta <-> Scala blog post
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