JSON can have data represented in about 5 primitive data types: String, Number, Array, Boolean, and Null. So if you are using express, and you have a javascript object that you would like to send to the client as json, the data fields(or object properties) will be cast to any of the respective data types. In this case of the base64 it will be sent as a
String type. Below is the example:
JavaScript Object:
Let user = new User({
username: 'some_username',
id: some base64 encoded value or variable
});
To send it as JSON using express, you would simply do the below(res being the request object of your express middle-ware):
res.json(user).send();
This way the payload sent to the client will be a JSON Object like below:
{
"username": "some_username",
"id": "YmFzZTY0IGRlY29kZXI"
}
I hope this helps and good luck! :)