Let's say I have a JSON message:
json_msg =
[{ LOG: 'TPT',
TYPE: 'UPDATE',
UIN: 'VEHICLE',
SEQ_NO: 20129,
VALUE: 1,
TIMESTAMP: 518342.438263017,
EXPERIMENT: 0,
IDENT: '.Model.Index_obj.MuLifeCycle_obj.Mu.vh_Transporter:2',
STAGE: 'START',
MODE: '' },
{ LOG: 'TPT',
TYPE: 'UPDATE',
UIN: 'VEHICLE',
SEQ_NO: 20129,
VALUE: 1,
TIMESTAMP: 518342.438263017,
EXPERIMENT: 0,
IDENT: '.Model.Index_obj.MuLifeCycle_obj.Mu.vh_Transporter:2',
STAGE: 'START',
MODE: '' }.
{ LOG: 'TPT',
TYPE: 'UPDATE',
UIN: 'VEHICLE',
SEQ_NO: 20129,
VALUE: 1,
TIMESTAMP: 518342.438263017,
EXPERIMENT: 0,
IDENT: '.Model.Index_obj.MuLifeCycle_obj.Mu.vh_Transporter:2',
STAGE: 'START',
MODE: '' }]
and I want to add it to an empty JSON object
var testObject = {}
Now, I need to iterate through the json messages and append them to testObject.
for (let i =0; i< json_msg.length; i++) {
// TODO
testObject.push(json_msg[i])} // doesn't work
Does anyone have a solution for this?
Keep in mind that this is just a test case. In reality, I filter incoming JSON messages and need a method to add these filtered messages into a new JSON Object message (similar to '.push' for arrays).