param.parameterized.Parameters.serialize_value#

Parameters.serialize_value(pname: str, mode: str = 'json')[source]#

Serialize the value of a specific parameter.

This method serializes the value of a given parameter on a Parameterized object using the specified serialization mode.

Parameters:
  • pname (str) – The name of the parameter whose value is to be serialized.

  • mode (str, optional) – The serialization format to use. By default, only 'json' is supported. Default is 'json'.

Returns:

The serialized value of the specified parameter.

Return type:

Any

Raises:

ValueError – If the specified serialization mode is not supported.

References

https://param.holoviz.org/user_guide/Serialization_and_Persistence.html#serializing-with-json

Examples

Serialize the value of a specific parameter:

>>> import param
>>> class P(param.Parameterized):
...     a = param.Number()
...     b = param.String()
>>> p = P(a=1, b="hello")

Serialize the value of parameter ‘a’:

>>> serialized_value = p.param.serialize_value('a')
>>> serialized_value
'1'