How do I create a base64 JSON encoded strings in nodejs?
I tried this and it didn't work.
var buff = new Buffer({"hello":"world"}).toString("base64");
Is this it?
var buff = new Buffer(JSON.stringify({"hello":"world"})).toString("base64");
var buff = new Buffer(JSON.stringify({"hello":"world"})).toString("base64");
Bufferaccepts either an integer, an array or a string. But not an object. If you want an object to be converted to JSON, you have to do this explicitly, just like you did in your second example. nodejs.org/api/buffer.html