Add an example on how to call the serialize() method.

stix2.0
Emmanuelle Vargas-Gonzalez 2018-06-08 15:42:59 -04:00
parent dbe9c3f087
commit 60da259805
1 changed files with 15 additions and 0 deletions

View File

@ -236,6 +236,21 @@ class _STIXBase(collections.Mapping):
optional properties set to the default value defined in the spec.
**kwargs: The arguments for a json.dumps() call.
Examples:
>>> import stix2
>>> identity = stix2.Identity(name='Example Corp.', identity_class='organization')
>>> print(identity.serialize(sort_keys=True))
{"created": "2018-06-08T19:03:54.066Z", ... "name": "Example Corp.", "type": "identity"}
>>> print(identity.serialize(sort_keys=True, indent=4))
{
"created": "2018-06-08T19:03:54.066Z",
"id": "identity--d7f3e25a-ba1c-447a-ab71-6434b092b05e",
"identity_class": "organization",
"modified": "2018-06-08T19:03:54.066Z",
"name": "Example Corp.",
"type": "identity"
}
Returns:
str: The serialized JSON object.