getPersonListR :: Handler Html
getPersonListR = do
urlRender <- getUrlRender
personEnts <- runDB $ selectList [] [Asc PersonId]
let jData = map (\(Entity personId person) ->
JPerson { jPersonPerson = person
, jPersonEditFormUrl = urlRender $ PersonEditFormR personId }
) personEnts
jsonData <- returnJson jData >>= return . toJsonText
defaultLayout $ do
toWidgetBody [julius|var data = #{rawJS jsonData}|]
$(widgetFile "person_list")
data JPerson = JPerson
{ jPersonPerson :: Person
, jPersonEditFormUrl :: Text
}
Showing posts with label json. Show all posts
Showing posts with label json. Show all posts
Tuesday, September 26, 2017
Yesod embed json in html
Saturday, January 25, 2014
store json into couchdb with curl
file q1.json:
{
"type": "quote",
"author": "Thomas Hardy",
"text": "And as the smart ship grew
In stature, grace, and hue
In shadowy silent distance grew the Iceberg too.",
"work": {
"title": "The Convergence Of The Twain",
"link": "http://www.poetryfoundation.org/poem/176678",
"year": 1915
}
}
curl -u user:passwd -X POST http://localhost:5984/example -H 'Content-Type: application/json' -d @q1.json
Subscribe to:
Posts (Atom)