From 878fb9f49174b29810561c56af6ad59414b9e9ee Mon Sep 17 00:00:00 2001 From: Dano van den Bosch Date: Thu, 7 Mar 2024 13:11:01 +0100 Subject: [PATCH] Refactor JSON parsing and data handling functions --- docs/brainstorm/SoftwareDocumentatie/Dev_page.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/brainstorm/SoftwareDocumentatie/Dev_page.md b/docs/brainstorm/SoftwareDocumentatie/Dev_page.md index 138990e..6d75aca 100644 --- a/docs/brainstorm/SoftwareDocumentatie/Dev_page.md +++ b/docs/brainstorm/SoftwareDocumentatie/Dev_page.md @@ -2,15 +2,17 @@ ### parsing JSON +The data that is send by the nodes is send in json data. We chose this becouse we can easily use the data within javascript, this is called parsing. We use the parced data and send that in to the next function to make the data more acceseble to use in further instences. + ```js const jsonData = JSON.parse(event.data); // Use the parsed JSON data as needed handleIncomingData(jsonData); ``` -### Pro - +Here is the function that receves the parced JSON data and set it into variables. +```js function handleIncomingData(data) { nodeNumber = data.node; temperature = data.Temp; @@ -20,7 +22,7 @@ function handleIncomingData(data) { processNodeData(nodeNumber, temperature, humidity, CO2, TVOC); } - +``` function processNodeData(nodeNumber, temperature, humidity, CO2, TVOC) { // Initialize the array for this node if it doesn't exist yet if (!sensorData[nodeNumber]) {