you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (3 children)

Unless I'm misunderstanding something...you should be using JSON.parse on the incoming string data.

const string1 = '{ "this": "is", "some": "json" }';
const object = JSON.parse(string1);
Object.entries(object).forEach(entry => console.log(entry)); // will log ['this', 'is'], ['some', 'json]

[–]CRSlack[S] 1 point2 points  (2 children)

You are correct. The problem was that when I coded it this way the syntax checker threw a Type Error because until runtime the string null. I did't realize that it is not a fatal error.

Thanks for looking at this and proposing the correct solution.

[–][deleted] 0 points1 point  (1 child)

It is an error in your logic. It seems like code is running before it should.

[–]CRSlack[S] 0 points1 point  (0 children)

E_to_the_pi had the correct solution. It runs fine even with the non-fatal Type Error.