Code example for JsonParser

Methods: parse

    private static final String TOKEN_REGEX = "\"access_token\":\"([^&\"]+)\"";
    private static final Logger LOG = LoggerFactory.getLogger(SliTokenExtractor.class); 
    public Token extract(String response) {
        Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
        JsonParser parser = new JsonParser();
        JsonObject json = parser.parse(response).getAsJsonObject();
        LOG.debug("Response to extract token from - " + json);
        return new Token(json.get("access_token").getAsString(), "", response);
Experience pair programming with AI  Get Codota for Java