Open this example in the interactive library
Source code
const record = { title: "Café", copies: 20 };
const bytes = new TextEncoder().encode(JSON.stringify(record));
console.log(JSON.parse(new TextDecoder().decode(bytes)));
Sample output
{ title: 'Café', copies: 20 }