Guard against a null Meta property in the scale event API

This commit is contained in:
Michael Lange 2020-12-07 12:28:23 -08:00
parent d0495e1b56
commit 58ecacc710
2 changed files with 19 additions and 0 deletions

View File

@ -20,6 +20,17 @@ export default class Application extends JSONSerializer {
*/
arrayNullOverrides = null;
/**
A list of keys that are converted to empty objects if their value is null.
objectNullOverrides = ['Object'];
{ Object: null } => { Object: {} }
@property objectNullOverrides
@type String[]
*/
objectNullOverrides = null;
/**
A list of keys or objects to convert a map into an array of maps with the original map keys as Name properties.
@ -90,6 +101,13 @@ export default class Application extends JSONSerializer {
}
});
}
if (this.objectNullOverrides) {
this.objectNullOverrides.forEach(key => {
if (!hash[key]) {
hash[key] = {};
}
});
}
if (this.mapToArray) {
this.mapToArray.forEach(conversion => {

View File

@ -2,4 +2,5 @@ import ApplicationSerializer from './application';
export default class ScaleEventSerializer extends ApplicationSerializer {
separateNanos = ['Time'];
objectNullOverrides = ['Meta'];
}