INNER CODE UNIT · Python
_build_json_content
atenreiro/opensquat · opensquat/cli.py:50
def _build_json_content(scanner, filtered_set):
"""
Build the JSON output structure: a list of per-keyword objects, each
with a "domains" array of {"domain": ..., ...} dicts.
In Premium API mode, scanner.keyword_domains_meta carries rich
LookalikeDomain objects and the output includes tld/date/idn/unicode
fields. In community/feed modes, only the bare domain string is
emitted as {"domain": ...}, keeping the top-level shape consistent
across all three modes.
"""
json_content = []
meta = getattr(scanner, "keyword_domains_meta", {}) or {}
for kw, doms in scanner.keyword_domains.items():
if kw in meta:
rich = [d for d in meta[kw] if d.domain in filtered_set]
if rich:
json_content.append({