Currently creating the parameter_value as JSON essentially "reimplements" by crafting the dictionaries by hand. Refactor it to use the Pydantic dataclasses, see: spinedb_api/parameter_value.py::to_list.
Existing tests should already cover this code, so a refactor should not break any tests.
Error handling
Parse pydantic errors to something friendlier, and raise ParameterValueFormatError.