So I have a poller that polls a device for a response that looks like this:
{"mode":"41","pid":"0C","name":"rpm","value":1817.75}
I have multiple pollers with similar responses. Say, another poller with the following response:
{"mode":"41","pid":"05","name":"temp","value":81}
Each poll takes place in a 500ms interval. I need to log all this data in a certain form.
What happens now?
I have a log that looks like this:
{"data": {"mode":"41","pid":"0C","name":"rpm","value":1817.75}, "time": "someTime" },
{"data": {"mode":"41","pid":"05","name":"temp","value":81}, "time": "someOtherTime" }
What I'm trying to achieve?
A log that looks like this:
{
"data": {
"rpm": {"mode":"41","pid":"0C","name":"rpm","value":1817.75},
"temp":{"mode":"41","pid":"05","name":"temp","value":81},
"time": newTime
},
"data": {
"rpm": {"mode":"41","pid":"0C","name":"rpm","value":1817.75},
"temp":{"mode":"41","pid":"05","name":"temp","value":81},
"time": newTime
},
"data": {
"rpm": {"mode":"41","pid":"0C","name":"rpm","value":1817.75},
"temp":{"mode":"41","pid":"05","name":"temp","value":81},
"time": newTime
},
}
I need to construct the object to look like the way I've mentioned. I'm sure there's a simple way to do it. Also, if there's a better way to do it, what would it be?