如何从lua解析github webhook?

时间:2016-05-29 10:12:56

标签: json parsing github lua cgi

我认为,这个tastk是微不足道的:我想用CGI lua脚本解析GitHub钩子。但是getted数据无效JSON,JSON库无法解析它。但它的格式是什么?我需要哪些模块来处理这些数据?

示例输入:

payload={"zen":"Keep it logically awesome.","hook_id":8556074,"hook":{"type":"Repository","id":8556074,"name":"web","active":true,"events":["push"],"config":{"content_type":"form","insecure_ssl":"0","url":"http://git.vallua.ru/git/update.cgi"},"updated_at":"2016-05-28T12:49:11Z","created_at":"2016-05-28T12:49:11Z","url":"https://api.github.com/repos/v1993/ProjectZ/hooks/8556074","test_url":"https://api.github.com/repos/v1993/ProjectZ/hooks/8556074/test","ping_url":"https://api.github.com/repos/v1993/ProjectZ/hooks/8556074/pings","last_response":{"code":null,"status":"unused","message":null}},"repository":{"id":50855609,"name":"ProjectZ","full_name":"v1993/ProjectZ","owner":{"login":"v1993","id":16255906,"avatar_url":"https://avatars.githubusercontent.com/u/16255906?v=3","gravatar_id":"","url":"https://api.github.com/users/v1993","html_url":"https://github.com/v1993","followers_url":"https://api.github.com/users/v1993/followers","following_url":"https://api.github.com/users/v1993/following{/other_user}","gists_url":"https://api.github.com/users/v1993/gists{/gist_id}","starred_url":"https://api.github.com/users/v1993/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/v1993/subscriptions","organizations_url":"https://api.github.com/users/v1993/orgs","repos_url":"https://api.github.com/users/v1993/repos","events_url":"https://api.github.com/users/v1993/events{/privacy}","received_events_url":"https://api.github.com/users/v1993/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/v1993/ProjectZ","description":"IIWG (aka ProjectZ) - Instead Infinite Worlds Generator (my project about infinite text worlds)","fork":false,"url":"https://api.github.com/repos/v1993/ProjectZ","forks_url":"https://api.github.com/repos/v1993/ProjectZ/forks","keys_url":"https://api.github.com/repos/v1993/ProjectZ/keys{/key_id}","collaborators_url":"https://api.github.com/repos/v1993/ProjectZ/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/v1993/ProjectZ/teams","hooks_url":"https://api.github.com/repos/v1993/ProjectZ/hooks","issue_events_url":"https://api.github.com/repos/v1993/ProjectZ/issues/events{/number}","events_url":"https://api.github.com/repos/v1993/ProjectZ/events","assignees_url":"https://api.github.com/repos/v1993/ProjectZ/assignees{/user}","branches_url":"https://api.github.com/repos/v1993/ProjectZ/branches{/branch}","tags_url":"https://api.github.com/repos/v1993/ProjectZ/tags","blobs_url":"https://api.github.com/repos/v1993/ProjectZ/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/v1993/ProjectZ/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/v1993/ProjectZ/git/refs{/sha}","trees_url":"https://api.github.com/repos/v1993/ProjectZ/git/trees{/sha}","statuses_url":"https://api.github.com/repos/v1993/ProjectZ/statuses/{sha}","languages_url":"https://api.github.com/repos/v1993/ProjectZ/languages","stargazers_url":"https://api.github.com/repos/v1993/ProjectZ/stargazers","contributors_url":"https://api.github.com/repos/v1993/ProjectZ/contributors","subscribers_url":"https://api.github.com/repos/v1993/ProjectZ/subscribers","subscription_url":"https://api.github.com/repos/v1993/ProjectZ/subscription","commits_url":"https://api.github.com/repos/v1993/ProjectZ/commits{/sha}","git_commits_url":"https://api.github.com/repos/v1993/ProjectZ/git/commits{/sha}","comments_url":"https://api.github.com/repos/v1993/ProjectZ/comments{/number}","issue_comment_url":"https://api.github.com/repos/v1993/ProjectZ/issues/comments{/number}","contents_url":"https://api.github.com/repos/v1993/ProjectZ/contents/{+path}","compare_url":"https://api.github.com/repos/v1993/ProjectZ/compare/{base}...{head}","merges_url":"https://api.github.com/repos/v1993/ProjectZ/merges","archive_url":"https://api.github.com/repos/v1993/ProjectZ/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/v1993/ProjectZ/downloads","issues_url":"https://api.github.com/repos/v1993/ProjectZ/issues{/number}","pulls_url":"https://api.github.com/repos/v1993/ProjectZ/pulls{/number}","milestones_url":"https://api.github.com/repos/v1993/ProjectZ/milestones{/number}","notifications_url":"https://api.github.com/repos/v1993/ProjectZ/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/v1993/ProjectZ/labels{/name}","releases_url":"https://api.github.com/repos/v1993/ProjectZ/releases{/id}","deployments_url":"https://api.github.com/repos/v1993/ProjectZ/deployments","created_at":"2016-02-01T17:06:10Z","updated_at":"2016-03-07T10:30:19Z","pushed_at":"2016-05-27T18:46:43Z","git_url":"git://github.com/v1993/ProjectZ.git","ssh_url":"git@github.com:v1993/ProjectZ.git","clone_url":"https://github.com/v1993/ProjectZ.git","svn_url":"https://github.com/v1993/ProjectZ","homepage":"","size":28,"stargazers_count":1,"watchers_count":1,"language":"Lua","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"},"sender":{"login":"v1993","id":16255906,"avatar_url":"https://avatars.githubusercontent.com/u/16255906?v=3","gravatar_id":"","url":"https://api.github.com/users/v1993","html_url":"https://github.com/v1993","followers_url":"https://api.github.com/users/v1993/followers","following_url":"https://api.github.com/users/v1993/following{/other_user}","gists_url":"https://api.github.com/users/v1993/gists{/gist_id}","starred_url":"https://api.github.com/users/v1993/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/v1993/subscriptions","organizations_url":"https://api.github.com/users/v1993/orgs","repos_url":"https://api.github.com/users/v1993/repos","events_url":"https://api.github.com/users/v1993/events{/privacy}","received_events_url":"https://api.github.com/users/v1993/received_events","type":"User","site_admin":false}}

0 个答案:

没有答案