I’ve got a JSON data set like so:
{ "ts": "4", "FlowvolMeas_dL_12_hr": "3612.82", "FlowvolUnexp_dL_12_hr": "40.26" },
{ "ts": "5", "FlowvolMeas_dL_12_hr": "237.15", "FlowvolUnexp_dL_12_hr": "0.98" },
{ "ts": "6", "FlowvolMeas_dL_12_hr": "12.04", "FlowvolUnexp_dL_12_hr": "0.2" },
…and another like so:
{ "ts": "4", "FlowvolMeas_dL_30_min": "12", "FlowvolUnexp_dL_12_hr": "2" },
{ "ts": "5", "FlowvolMeas_dL_30_min": "22", "FlowvolUnexp_dL_12_hr": "3" },
{ "ts": "6", "FlowvolMeas_dL_30_min": "33", "FlowvolUnexp_dL_12_hr": "4" }, ...
And what I hoping to do is do a sort of global addition of two fields without needing to individually define each case, ie 30_min and 12_hr, then append that total to the end of the ‘record’.
Some sort of loop I am thinking of that when I encounter anything with a prefix of ‘FlowvolMeas’ and ‘FlowvolUnexp’, I add the two values together and append the total to the end of that same record, effectively ignoring the 12_hr or 30_min parts.
Something like a wildcard search perhaps? like whatever the javascript equivalent of total = FlowvolMeas* + FlowvolUnexp*
would be, followed by appending that new key:value pair to the end of the record.
Just not sure how to go about it. Any help or pointing in right direction is appreciated and feel free to point me to existing solutions. I poked around but did not see anything specific that I could safely cobble together.