{"action":"created","issue":{"url":"https://api.github.com/repos/sailorproject/sailor/issues/86","repository_url":"https://api.github.com/repos/sailorproject/sailor","labels_url":"https://api.github.com/repos/sailorproject/sailor/issues/86/labels{/name}","comments_url":"https://api.github.com/repos/sailorproject/sailor/issues/86/comments","events_url":"https://api.github.com/repos/sailorproject/sailor/issues/86/events","html_url":"https://github.com/sailorproject/sailor/issues/86","id":134843797,"number":86,"title":"Add a page:json function","user":{"login":"louis77","id":1240462,"avatar_url":"https://avatars.githubusercontent.com/u/1240462?v=3","gravatar_id":"","url":"https://api.github.com/users/louis77","html_url":"https://github.com/louis77","followers_url":"https://api.github.com/users/louis77/followers","following_url":"https://api.github.com/users/louis77/following{/other_user}","gists_url":"https://api.github.com/users/louis77/gists{/gist_id}","starred_url":"https://api.github.com/users/louis77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/louis77/subscriptions","organizations_url":"https://api.github.com/users/louis77/orgs","repos_url":"https://api.github.com/users/louis77/repos","events_url":"https://api.github.com/users/louis77/events{/privacy}","received_events_url":"https://api.github.com/users/louis77/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-19T11:35:38Z","updated_at":"2016-02-22T07:57:41Z","closed_at":null,"body":"Since returning JSON content is such a common case now, I propose to add a json function to the page module, where I just pass a variable plus options (which are passed to dkjson), like so:\r\n\r\n```\r\npage:json( data, { indent = true })\r\n```\r\n\r\nThis essentially should do:\r\n\r\n```\r\nlocal json = require \"dkjson\"\r\npage.theme = nil\r\npage.layout = nil\r\npage.r.content_type = 'application/json'\r\npage:write(json.encode(data, {indent=true}))\r\n```\r\n\r\nWhat do you think?"},"comment":{"url":"https://api.github.com/repos/sailorproject/sailor/issues/comments/187060577","html_url":"https://github.com/sailorproject/sailor/issues/86#issuecomment-187060577","issue_url":"https://api.github.com/repos/sailorproject/sailor/issues/86","id":187060577,"user":{"login":"louis77","id":1240462,"avatar_url":"https://avatars.githubusercontent.com/u/1240462?v=3","gravatar_id":"","url":"https://api.github.com/users/louis77","html_url":"https://github.com/louis77","followers_url":"https://api.github.com/users/louis77/followers","following_url":"https://api.github.com/users/louis77/following{/other_user}","gists_url":"https://api.github.com/users/louis77/gists{/gist_id}","starred_url":"https://api.github.com/users/louis77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/louis77/subscriptions","organizations_url":"https://api.github.com/users/louis77/orgs","repos_url":"https://api.github.com/users/louis77/repos","events_url":"https://api.github.com/users/louis77/events{/privacy}","received_events_url":"https://api.github.com/users/louis77/received_events","type":"User","site_admin":false},"created_at":"2016-02-22T07:57:41Z","updated_at":"2016-02-22T07:57:41Z","body":"Any preferences/experience to share with the available JSON libraries? Personally I like https://luarocks.org/modules/dhkolf/dkjson because it's free of dependencies, fast and I never had any decoding issues with it."}}