diff --git a/sources/Commands/CommandParser.uc b/sources/Commands/CommandParser.uc index c78edfc..a3a03ba 100644 --- a/sources/Commands/CommandParser.uc +++ b/sources/Commands/CommandParser.uc @@ -449,6 +449,9 @@ private final function bool ParseSingleValue( else if (expectedParameter.type == CPT_Array) { return ParseArrayValue(parsedParameters, expectedParameter); } + else if (expectedParameter.type == CPT_JSON) { + return ParseJSONValue(parsedParameters, expectedParameter); + } return false; } @@ -615,6 +618,23 @@ private final function bool ParseArrayValue( return true; } +// Assumes `commandParser` and `parsedParameters` are not `none`. +// Parses a single JSON value into given `parsedParameters` +// hash table. +private final function bool ParseJSONValue( + HashTable parsedParameters, + Command.Parameter expectedParameter) +{ + local AcediaObject jsonValue; + + jsonValue = _.json.ParseWith(commandParser); + if (!commandParser.Ok()) { + return false; + } + RecordParameter(parsedParameters, expectedParameter, jsonValue); + return true; +} + // Assumes `parsedParameters` is not `none`. // Records `value` for a given `parameter` into a given `parametersArray`. // If parameter is not a list type - simply records `value` as value under