flattenJSON static method
dynamic
flattenJSON(
- dynamic jsonKeys,
- dynamic times,
- dynamic values,
- dynamic valuePropertyName,
Implementation
static flattenJSON(jsonKeys, times, values, valuePropertyName) {
var i = 1, key = jsonKeys[0];
while (key != null && key[valuePropertyName] == null) {
key = jsonKeys[i++];
}
if (key == null) return; // no data
var value = key[valuePropertyName];
if (value == null) return; // no data
if (value is List) {
do {
value = key[valuePropertyName];
if (value != null) {
times.push(key.time);
values.push.apply(values, value); // push all elements
}
key = jsonKeys[i++];
} while (key != null);
} else if (value.toArray != null) {
// ...assume three.Math-ish
do {
value = key[valuePropertyName];
if (value != null) {
times.push(key.time);
value.toArray(values, values.length);
}
key = jsonKeys[i++];
} while (key != null);
} else {
// otherwise push as-is
do {
value = key[valuePropertyName];
if (value != null) {
times.push(key.time);
values.push(value);
}
key = jsonKeys[i++];
} while (key != null);
}
}