diff options
| author | troido <troido@protonmail.com> | 2020-04-06 16:01:00 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-06 16:01:00 +0200 |
| commit | 66a3d3131f32e7bae2f0f7c4fd0b0c876eb3e8a0 (patch) | |
| tree | b6e7fe873be9c17b49596946543ee24f3771745d /src/componentparameter.rs | |
| parent | e8d3e3c4f69fc5bab2b32b16b7c8c2c4a8a89a4b (diff) | |
shortcut or defining some entities like crops
Diffstat (limited to 'src/componentparameter.rs')
| -rw-r--r-- | src/componentparameter.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/componentparameter.rs b/src/componentparameter.rs index 73c7b30..47c9a26 100644 --- a/src/componentparameter.rs +++ b/src/componentparameter.rs @@ -63,6 +63,9 @@ impl ComponentParameter { } pub fn from_json(value: &Value) -> PResult<Self> { + if !value.is_array() { + return Ok(Self::Constant(Parameter::guess_from_json(value).ok_or(perr!("invalid component parameter {:?}", value))?)); + } let paramvalue = value.get(1).ok_or(perr!("index 1 not in component parameter"))?; let typename = value.get(0).ok_or(perr!("index 0 not in component parameter"))?.as_str().ok_or(perr!("compparam type not a string"))?; if let Some(paramtype) = ParameterType::from_str(typename) { @@ -101,7 +104,7 @@ impl ComponentParameter { pub fn get_type(&self, arguments: &[(String, ParameterType, Option<Parameter>)]) -> Result<ParameterType>{ Ok(match self { Self::Constant(param) => param.paramtype(), - Self::Argument(argname) => arguments.iter().find(|(n, _t, _d)| n == argname).ok_or(aerr!("unknown argument name"))?.1, + Self::Argument(argname) => arguments.iter().find(|(n, _t, _d)| n == argname).ok_or(aerr!("unknown argument name {} in {:?}", argname, arguments))?.1, Self::Random(options) => { let typ: ParameterType = options.get(0).ok_or(aerr!("random has no options"))?.get_type(arguments)?; for param in options { |
