Skip to content

Commit

Permalink
Json stringify object measurements
Browse files Browse the repository at this point in the history
This change will e.g. make the values of `typing.NamedTuple`s visible in the Web UI. Before this change they were displayed as `[object Object]`.
I believe the measurements are guaranteed to be json-serializable because they are coming in via the websocket transport, which uses json already.
  • Loading branch information
lalten committed Oct 11, 2022
1 parent 7581ab2 commit a8fa970
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ function makePhase(phase: RawPhase, running: boolean) {
measurements = Object.keys(phase.measurements).map(key => {
const rawMeasuredValue = phase.measurements[key].measured_value;
let measuredValue = null;
if (typeof rawMeasuredValue !== 'undefined') {
if (typeof rawMeasuredValue === 'object') {
measuredValue = JSON.stringify(rawMeasuredValue);
} else if (typeof rawMeasuredValue !== 'undefined') {
measuredValue = `${rawMeasuredValue}`;
}
return new Measurement({
Expand Down

0 comments on commit a8fa970

Please sign in to comment.