@@ -561,26 +561,23 @@ def json_description(self) -> str:
561
561
"""
562
562
return self .__class__ .__doc__ or "Generated with PyCardano"
563
563
564
- def to_json (self , ** kwargs ) -> str :
564
+ def to_json (self , key_type : Optional [ str ] = None , description : Optional [ str ] = None ) -> str :
565
565
"""
566
566
Convert the CBORSerializable object to a JSON string containing type, description, and CBOR hex.
567
567
568
568
This method returns a JSON representation of the object, including its type, description, and CBOR hex encoding.
569
569
570
570
Args:
571
- **kwargs: Additional keyword arguments that can include:
572
- - key_type (str): The type to use in the JSON output. Defaults to the class name.
573
- - description (str): The description to use in the JSON output. Defaults to the class docstring.
571
+ key_type (str): The type to use in the JSON output. Defaults to the class name.
572
+ description (str): The description to use in the JSON output. Defaults to the class docstring.
574
573
575
574
Returns:
576
575
str: The JSON string representation of the object.
577
576
"""
578
- key_type = kwargs .pop ("key_type" , self .json_type )
579
- description = kwargs .pop ("description" , self .json_description )
580
577
return json .dumps (
581
578
{
582
- "type" : key_type ,
583
- "description" : description ,
579
+ "type" : key_type or self . json_type ,
580
+ "description" : description or self . json_description ,
584
581
"cborHex" : self .to_cbor_hex (),
585
582
},
586
583
indent = 2 ,
@@ -625,8 +622,8 @@ def save(
625
622
626
623
Args:
627
624
path (str): The file path to save the object to.
628
- key_type (str, optional): The type to use in the JSON output.
629
- description (str, optional): The description to use in the JSON output.
625
+ key_type (str, optional): The type to use in the JSON output. Defaults to the class name.
626
+ description (str, optional): The description to use in the JSON output. Defaults to the class docstring.
630
627
631
628
Raises:
632
629
IOError: If the file already exists and is not empty.
0 commit comments