Skip to content

Instantly share code, notes, and snippets.

@JulienSansot
Created August 25, 2014 01:10
Show Gist options
  • Save JulienSansot/656c396fab947a462e4e to your computer and use it in GitHub Desktop.
Save JulienSansot/656c396fab947a462e4e to your computer and use it in GitHub Desktop.
printing javascript object in the page
<div>
</div>
<script>
var o = {
test1 : 50,
test2 : 'Test',
test3: {
test4: 'test1',
test5: [1,2,3]
}
};
var str = JSON.stringify(o, null, 6);
str = str.replace(/\n/g, '<br/>').replace(/ /g, '&nbsp;').replace(/"/g, "");
$("div").html(str);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment