With javascript
you can transform a json
into texto
using the stringify()
function, after the conversion included in your HTML
normally.
let json = JSON.stringify({"Language":"PT-BR", "TransactionID":"1234567890"});
const codeArea = document.querySelector('.code-area');
codeArea.innerHTML = json;
See the example:
const raw = {"Language":"PT-BR","TransactionID":"1234567890"};
const button = document.querySelector('.button');
const codeArea = document.querySelector('.code-area');
let json = JSON.stringify(raw);
button.addEventListener('click', function(){
codeArea.innerHTML = json;
});
<code class="code-area"></code>
<button class="button">Click</button>