I am trying javascript to print out json data.
https://devsheet.com/code-snippet/editorjs-blocks-json-to-html-javascript/
I have tried this sample code but undefined problem occurs.
obj = '{"header":"John", "paragraph":30, "list":"New York"}';
html = '';
Object.keys(obj).forEach(function(block, index) {
console.log(block['type']); // it prints undefined, it is expected to print keys (header, paragraph, etc.)
switch (block['type']) {
case 'paragraph':
html += '<p>'+ block['data']['text'] +'</p>';
break;
case 'header':
html += '<h'+ block['data']['level'] +'>'+ block['data']['text'] +'</h'+ block['data']['level'] +'>';
break;
...
...
console.log(block[‘type’]); <—- it prints undefined, it is expected to print keys (header, paragraph, etc.)
How can I solve it?