From 60da25980580f6c9b04306c0b49a18d48728d2d3 Mon Sep 17 00:00:00 2001 From: Emmanuelle Vargas-Gonzalez Date: Fri, 8 Jun 2018 15:42:59 -0400 Subject: [PATCH] Add an example on how to call the serialize() method. --- stix2/base.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/stix2/base.py b/stix2/base.py index 2afba16..0ba6f56 100644 --- a/stix2/base.py +++ b/stix2/base.py @@ -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.