Groovy web console

subscribe to the feed Subscribe
to this
site
json (via #groovywebconsole)
tweet this snippet Tweet
this
script

json

Published 4 months ago by nmrao with tags json
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def json = """[{
        "url": "https://api.github.com/repos/myname/repo/releases/12",
        "assets_url": "https://api.github.com/repos/myname/repo/releases/12/assets",
        "upload_url": "https://uploads.github.com/repos/myname/repo/releases/12/assets{?name,label}",
        "html_url": "https://github.com/myname/repo/releases/tag/12.4.4",
        "id": 123,
        "tag_name": "12.4.4",
        "target_commitish": "master",
        "name": "12.4.4",
        "draft": false,
        "author": {
            "login": "org",
            "id": 123,
            "avatar_url": "https://avatars2.githubusercontent.com/u/123?v=3",
            "gravatar_id": "",
            "url": "https://api.github.com/users/org",
            "html_url": "https://github.com/org",
            "followers_url": "https://api.github.com/users/org/followers",
            "following_url": "https://api.github.com/users/org/following{/other_user}",
            "gists_url": "https://api.github.com/users/org/gists{/gist_id}",
            "starred_url": "https://api.github.com/users/org/starred{/owner}{/repo}",
            "subscriptions_url": "https://api.github.com/users/org/subscriptions",
            "organizations_url": "https://api.github.com/users/org/orgs",
            "repos_url": "https://api.github.com/users/org/repos",
            "events_url": "https://api.github.com/users/org/events{/privacy}",
            "received_events_url": "https://api.github.com/users/org/received_events",
            "type": "User",
            "site_admin": false
        },
        "prerelease": true,
        "created_at": "2017-06-01T09:38:32Z",
        "published_at": "2017-06-06T11:46:09Z",
        "assets": [{
                "url": "https://api.github.com/repos/myname/repo/releases/assets/123",
                "id": 123,
                "name": "repo-8.4.4.aar",
                "label": "",
                "uploader": {
                    "login": "org",
                    "id": 123,
                    "avatar_url": "https://avatars5.githubusercontent.com/u/123?v=3",
                    "gravatar_id": "",
                    "url": "https://api.github.com/users/org",
                    "html_url": "https://github.com/org",
                    "followers_url": "https://api.github.com/users/org/followers",
                    "following_url": "https://api.github.com/users/org/following{/other_user}",
                    "gists_url": "https://api.github.com/users/org/gists{/gist_id}",
                    "starred_url": "https://api.github.com/users/org/starred{/owner}{/repo}",
                    "subscriptions_url": "https://api.github.com/users/org/subscriptions",
                    "organizations_url": "https://api.github.com/users/org/orgs",
                    "repos_url": "https://api.github.com/users/org/repos",
                    "events_url": "https://api.github.com/users/org/events{/privacy}",
                    "received_events_url": "https://api.github.com/users/org/received_events",
                    "type": "User",
                    "site_admin": false
                },
                "content_type": "application/zip",
                "state": "uploaded",
                "size": 155192,
                "download_count": 0,
                "created_at": "2017-06-06T11:46:11Z",
                "updated_at": "2017-06-06T11:46:12Z",
                "browser_download_url": "https://github.com/myname/repo/releases/download/4.4/repo-12.4.4.aar"
            },
            {
                "url": "https://api.github.com/repos/myname/repo/releases/assets/123",
                "id": 123,
                "name": "repo-5.2.0.aar",
                "label": "",
                "uploader": {
                    "login": "org",
                    "id": 20902440,
                    "avatar_url": "https://avatars3.githubusercontent.com/u/123?v=3",
                    "gravatar_id": "",
                    "url": "https://api.github.com/users/org",
                    "html_url": "https://github.com/org",
                    "followers_url": "https://api.github.com/users/org/followers",
                    "following_url": "https://api.github.com/users/org/following{/other_user}",
                    "gists_url": "https://api.github.com/users/org/gists{/gist_id}",
                    "starred_url": "https://api.github.com/users/org/starred{/owner}{/repo}",
                    "subscriptions_url": "https://api.github.com/users/org/subscriptions",
                    "organizations_url": "https://api.github.com/users/org/orgs",
                    "repos_url": "https://api.github.com/users/org/repos",
                    "events_url": "https://api.github.com/users/org/events{/privacy}",
                    "received_events_url": "https://api.github.com/users/org/received_events",
                    "type": "User",
                    "site_admin": false
                },
                "content_type": "application/zip",
                "state": "uploaded",
                "size": 1779617,
                "download_count": 0,
                "created_at": "2017-06-06T11:46:12Z",
                "updated_at": "2017-06-06T11:46:13Z",
                "browser_download_url": "https://github.com/myname/repo/releases/download/.4.4/repo-5.2.0.aar"
            }
        ],
        "tarball_url": "https://api.github.com/repos/myname/repo/tarball/12.4.4",
        "zipball_url": "https://api.github.com/repos/myname/repo/zipball/12.4.4",
        "body": "[MYSTATS-2695](jira.dev.company.co.uk/browse/…) - Jenkins build pipeline should ignore draft and pre-releases\r\n"
    },
    {
        "url": "https://api.github.com/repos/myname/repo/releases/123",
        "assets_url": "https://api.github.com/repos/myname/repo/releases/6616643/assets",
        "upload_url": "https://uploads.github.com/repos/myname/repo/releases/6616643/assets{?name,label}",
        "html_url": "https://github.com/myname/repo/releases/tag/.4.3",
        "id": 6616643,
        "tag_name": "12.4.3",
        "target_commitish": "develop",
        "name": "Test Release",
        "draft": false,
        "author": {
            "login": "myname",
            "id": 1084186,
            "avatar_url": "https://avatars5.githubusercontent.com/u/123?v=3",
            "gravatar_id": "",
            "url": "https://api.github.com/users/myname",
            "html_url": "https://github.com/myname",
            "followers_url": "https://api.github.com/users/myname/followers",
            "following_url": "https://api.github.com/users/myname/following{/other_user}",
            "gists_url": "https://api.github.com/users/myname/gists{/gist_id}",
            "starred_url": "https://api.github.com/users/myname/starred{/owner}{/repo}",
            "subscriptions_url": "https://api.github.com/users/myname/subscriptions",
            "organizations_url": "https://api.github.com/users/myname/orgs",
            "repos_url": "https://api.github.com/users/myname/repos",
            "events_url": "https://api.github.com/users/myname/events{/privacy}",
            "received_events_url": "https://api.github.com/users/myname/received_events",
            "type": "User",
            "site_admin": false
        },
        "prerelease": false,
        "created_at": "2017-06-06T09:39:44Z",
        "published_at": "2017-06-06T11:44:43Z",
        "assets": [

        ],
        "tarball_url": "https://api.github.com/repos/myname/repo/tarball/.4.3",
        "zipball_url": "https://api.github.com/repos/myname/repo/zipball/.4.3",
        "body": ""
    }
]"""
list = new groovy.json.JsonSlurper().parseText(json)
println new groovy.json.JsonBuilder(list.findAll{ it.prerelease != true }).toPrettyString()