Following works in nodejs 4.2.3. But I don't see any documentation saying JSON.parse() accepts a buffer. Is this behavior guaranteed but not documented oris there something I'm doing wrong?
o = {"tes": 1, "4 byte utf8": "𠜎 𠜱 𠝹 𠱓"}; // { tes: 1, '4 byte utf8': '𠜎 𠜱 𠝹 𠱓' }
buffer = new Buffer(JSON.stringify(o), 'utf8'); // <Buffer 7b 22 74 65 73 22 3a 31 2c 22 34 20 62 79 74 65 20 75 74 66 38 22 3a 22 f0 a0 9c 8e 20 f0 a0 9c b1 20 f0 a0 9d b9 20 f0 a0 b1 93 22 7d>
JSON.parse(buffer); // { tes: 1, '4 byte utf8': '𠜎 𠜱 𠝹 𠱓' }
Thanks