Needing help with parsing JSON into an object

Hi there.

I’m relatively new to JavaScript and web development. Three weeks ago I read a “Beginner to Professional” book on JavaScript so I could build a web server which can connect to my software application that I created, send data to a database and display it and render a web page displaying some of the data to the end user.

I have got it all working in the way I want it except for one last bit. My software successfully sends JSON data to my web server which it receives. My software converts an array and sends something like this for example:

{“matchnumber”:1, “tablenumber”:1, “roundname”:“qualifier”}

My Node.JS server which I’m currently running on Visual Studio Code on localhost is receiving the message fine. I output it to the console using “req.body” and it returns it like this:

[Object: null prototype] { ‘{“matchnumber”:1, “tablenumber”:1, “roundname”:“qualifier”}’: ‘’}

Obviously I want the first set of curly brackets to be square brackets so it becomes an array so I can extract the data from the object. If I use JSON.parse() on the above I get an error message saying it cannot parse it.

Can anyone help me as to what I’m doing wrong here. It’s literally the last step I need to have my server fully functioning.

Thanks, Aaron

this is an object where the key is {“matchnumber”:1, “tablenumber”:1, “roundname”:“qualifier”} and the value is an empty string. You need to fix where the object is generated

Ah thank you so much! Now I see the mistake! Thank you!

Apologies for my lack of understanding. I’ve been playing around for an hour and still can’t seem to get it to work. When you said “I need to fix where the object is generated”, did you mean my software sending the data or something within my server when it receives it? Apologies for my sparse knowledge.

Thanks, Aaron.

I don’t know, I have no idea what your code is, you have provided absolutely no code

It’s fine! I’ve worked it out. I was forgetting to set a header to the server telling it about the JSON. Sorry for the confusion. I’ve got it working now!

Thanks, Aaron.