Recently I had integrated Google sign using AWS Cognito in my Next.js application. I had mapped the Google attributes with some custom attributes in my user pool.

So custom field custom:social_gender was mapped to Google attribute genders. I had received the value in the custom gender field as encoded string. Here is a sample,

'%7B%22resourceName%22%3A%22people%2FXXXXXXXXXXXXXXXXXXXX%22%2C%22etag%22%3A%22XXXXXXXXXXXXXXXXXXXXX%22%2C%22genders%22%3A%5B%7B%22metadata%22%3A%7B%22primary%22%3Atrue%2C%22source%22%3A%7B%22type%22%3A%22PROFILE%22%2C%22id%22%3A%22XXXXXXXXXXXXXXXXXXXX%22%7D%7D%2C%22value%22%3A%22male%22%2C%22formattedValue%22%3A%22Male%22%7D%5D%2C%22birthdays%22%3A%5B%7B%22metadata%22%3A%7B%22primary%22%3Atrue%2C%22source%22%3A%7B%22type%22%3A%22ACCOUNT%22%2C%22id%22%3A%22XXXXXXXXXXXXXXXXXXXX%22%7D%7D%2C%22date%22%3A%7B%22year%22%3A1901%2C%22month%22%3A1%2C%22day%22%3A1%7D%7D%5D%7D'

Here is how I parsed the data,

let encoded_data = '%7B%22resourceName%22%3A%22people%2FXXXXXXXXXXXXXXXXXXXX%22%2C%22etag%22%3A%22XXXXXXXXXXXXXXXXXXXXX%22%2C%22genders%22%3A%5B%7B%22metadata%22%3A%7B%22primary%22%3Atrue%2C%22source%22%3A%7B%22type%22%3A%22PROFILE%22%2C%22id%22%3A%22XXXXXXXXXXXXXXXXXXXX%22%7D%7D%2C%22value%22%3A%22male%22%2C%22formattedValue%22%3A%22Male%22%7D%5D%2C%22birthdays%22%3A%5B%7B%22metadata%22%3A%7B%22primary%22%3Atrue%2C%22source%22%3A%7B%22type%22%3A%22ACCOUNT%22%2C%22id%22%3A%22XXXXXXXXXXXXXXXXXXXX%22%7D%7D%2C%22date%22%3A%7B%22year%22%3A1901%2C%22month%22%3A1%2C%22day%22%3A1%7D%7D%5D%7D';
let parsed_data = JSON.parse(decodeURIComponent(encoded_data));
console.log(parsed_data);
/* 
// ## the encoded data was parsed into a JSON object
{
    "resourceName": "people/XXXXXXXXXXXXXXXXXXXX",
    "etag": "XXXXXXXXXXXXXXXXXXXXX",
    "genders": [
        {
            "metadata": {
                "primary": true,
                "source": {
                    "type": "PROFILE",
                    "id": "XXXXXXXXXXXXXXXXXXXX"
                }
            },
            "value": "male",
            "formattedValue": "Male"
        }
    ],
    "birthdays": [
        {
            "metadata": {
                "primary": true,
                "source": {
                    "type": "ACCOUNT",
                    "id": "XXXXXXXXXXXXXXXXXXXX"
                }
            },
            "date": {
                "year": 1901,
                "month": 1,
                "day": 1
            }
        }
    ]
}
*/