Code example for JsonParser

Methods: parse

0
        } 
    } 
 
    private static String extractAccessToken(String authString) {
        Log.d(TAG, "Extracting access token from: " + authString);
        JsonParser parser = new JsonParser();
        JsonObject authJson = parser.parse(authString).getAsJsonObject();
        String accessToken = null;
        if (authJson.has("p1cn_access_token")) {
            accessToken = authJson.get("p1cn_access_token").getAsString();
        } else if (authJson.has("activation_access_token")) {
            accessToken = authJson.get("activation_access_token").getAsString();
        } 
 
        if (accessToken == null || accessToken.equals("")) {
            throw new InvalidParameterException(
                    "Failed extracting access token"); 
        } 
        return accessToken;
 
Experience pair programming with AI  Get Codota for Java