<jupyter_start><jupyter_text>Serializing STIX Objects The string representation of all STIX classes is a valid STIX JSON object.<jupyter_code>from stix2 import Indicator

indicator = Indicator(name="File hash for malware variant",
                      pattern_type="stix",
                      pattern="[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']")

print(str(indicator))<jupyter_output><empty_output><jupyter_text>However, the string representation can be slow, as it sorts properties to be in a more readable order. If you need performance and don't care about the human-readability of the output, use the object's `serialize()` function:<jupyter_code>print(indicator.serialize())<jupyter_output><empty_output><jupyter_text>If you need performance but also need human-readable output, you can pass the `indent` keyword argument to `serialize()`:<jupyter_code>print(indicator.serialize(indent=4))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08936170212765958, 'fraction_numerical': 0.02553191489361702, 'mean_word_length': 5.919117647058823, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '314976', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 302, 'n_tokens_neox': 277, 'n_words': 81, 'path': 'docs/guide/serializing.ipynb', 'repo_name': '6un9-h0-Dan/cti-python-stix2', 'size': '940'}