Skip to content

Instantly share code, notes, and snippets.

@htr3n
Created November 4, 2021 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save htr3n/6d4109849672879f6a40f298b29df872 to your computer and use it in GitHub Desktop.
Save htr3n/6d4109849672879f6a40f298b29df872 to your computer and use it in GitHub Desktop.
Create an object from a base64 encoded input JSON string in Node.js
const inputStr = ... ; // a base64 encoded string
if (inputStr) {
const decodedStr = Buffer.from(inputStr, 'base64').toString('utf8');
const result = JSON.parse(decodedStr);
if (result) {
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment