Last active
September 7, 2017 22:40
-
-
Save vivek/62d2458c0488d7d6da710946e7778be0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.annotation.JsonProperty; | |
import com.fasterxml.jackson.databind.DeserializationFeature; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.fasterxml.jackson.databind.introspect.VisibilityChecker; | |
import org.kohsuke.github.GHBranch; | |
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY; | |
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; | |
public class Test { | |
static final ObjectMapper om = new ObjectMapper(); | |
static { | |
om.setVisibilityChecker(new VisibilityChecker.Std(NONE, NONE, NONE, NONE, ANY)); | |
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |
} | |
public static void main(String[] args) throws Exception { | |
String json = "{\"name\":\"b1\",\"commit\":{\"sha\":\"fafca8f366f5a40d9b28746262a3159dd38b98da\",\"commit\":{\"author\":{\"name\":\"Vivek Pandey\",\"email\":\"vivek.pandey@gmail.com\",\"date\":\"2017-09-07T21:18:04Z\"},\"committer\":{\"name\":\"Vivek Pandey\",\"email\":\"vivek.pandey@gmail.com\",\"date\":\"2017-09-07T21:18:04Z\"},\"message\":\"Added Jenkinsfile\",\"tree\":{\"sha\":\"4a6ecb363c01b4266bd2db5e77a60034ddaee714\",\"url\":\"https://api.github.com/repos/vivek/empty1/git/trees/4a6ecb363c01b4266bd2db5e77a60034ddaee714\"},\"url\":\"https://api.github.com/repos/vivek/empty1/git/commits/fafca8f366f5a40d9b28746262a3159dd38b98da\",\"comment_count\":0},\"url\":\"https://api.github.com/repos/vivek/empty1/commits/fafca8f366f5a40d9b28746262a3159dd38b98da\",\"html_url\":\"https://github.com/vivek/empty1/commit/fafca8f366f5a40d9b28746262a3159dd38b98da\",\"comments_url\":\"https://api.github.com/repos/vivek/empty1/commits/fafca8f366f5a40d9b28746262a3159dd38b98da/comments\",\"author\":{\"login\":\"vivek\",\"id\":38139,\"avatar_url\":\"https://avatars1.githubusercontent.com/u/38139?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/vivek\",\"html_url\":\"https://github.com/vivek\",\"followers_url\":\"https://api.github.com/users/vivek/followers\",\"following_url\":\"https://api.github.com/users/vivek/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/vivek/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/vivek/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/vivek/subscriptions\",\"organizations_url\":\"https://api.github.com/users/vivek/orgs\",\"repos_url\":\"https://api.github.com/users/vivek/repos\",\"events_url\":\"https://api.github.com/users/vivek/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/vivek/received_events\",\"type\":\"User\",\"site_admin\":false},\"committer\":{\"login\":\"vivek\",\"id\":38139,\"avatar_url\":\"https://avatars1.githubusercontent.com/u/38139?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/vivek\",\"html_url\":\"https://github.com/vivek\",\"followers_url\":\"https://api.github.com/users/vivek/followers\",\"following_url\":\"https://api.github.com/users/vivek/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/vivek/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/vivek/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/vivek/subscriptions\",\"organizations_url\":\"https://api.github.com/users/vivek/orgs\",\"repos_url\":\"https://api.github.com/users/vivek/repos\",\"events_url\":\"https://api.github.com/users/vivek/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/vivek/received_events\",\"type\":\"User\",\"site_admin\":false},\"parents\":[{\"sha\":\"323bf9ade63f9823a1489423b674a68d89dfdf52\",\"url\":\"https://api.github.com/repos/vivek/empty1/commits/323bf9ade63f9823a1489423b674a68d89dfdf52\",\"html_url\":\"https://github.com/vivek/empty1/commit/323bf9ade63f9823a1489423b674a68d89dfdf52\"}]},\"_links\":{\"self\":\"https://api.github.com/repos/vivek/empty1/branches/b1\",\"html\":\"https://github.com/vivek/empty1/tree/b1\"},\"protected\":false,\"protection\":{\"enabled\":false,\"required_status_checks\":{\"enforcement_level\":\"off\",\"contexts\":[]}},\"protection_url\":\"https://api.github.com/repos/vivek/empty1/branches/b1/protection\"}"; | |
GHBranch branch = om.readValue(json, GHBranch.class); | |
System.out.println(branch.isProtected()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment