FunctionArgument.fromJson constructor
FunctionArgument.fromJson(
- Map<String, dynamic> json
)
Implementation
factory FunctionArgument.fromJson(Map<String, dynamic> json) {
final jsonValue = json['value'];
final jsonName = json['name'];
if (jsonValue is Map<String, dynamic>) {
if (jsonName == "tagExpression") {
return FunctionArgument.fromJson({
"name": jsonName,
"type": "function",
"value": jsonValue['arguments'],
});
}
// SERIES BY TAG Or Other Functions
return FunctionArgument(
name: jsonName,
type: 'function',
value: GraphiteFunction.fromJson(jsonValue),
);
}
if (jsonValue is List && jsonName != "tagExpression") {
return FunctionArgument(
name: "seriesLists",
type: 'array',
value: (jsonValue).map(
(e) {
return GraphiteFunction.fromJson(e);
},
).toList(),
);
}
// TAG EXPRESSION
if (jsonValue is List) {
return FunctionArgument(
name: jsonName,
type: "array",
value: jsonValue
.map(
(e) => FunctionArgument(
name: e['name'],
type: e['value'].runtimeType.toString() == 'String'
? 'string'
: 'number',
value: e['value'],
),
)
.toList(),
);
}
return FunctionArgument(
name: jsonName,
type: jsonValue.runtimeType.toString() == 'String' ? 'string' : 'number',
value: jsonValue,
);
}