<｜begin▁of▁sentence｜>### Instruction:
As a Smart Home Designer, you are tasked with optimizing the automation and integration of smart devices within a residential property to enhance comfort and energy efficiency. You have been provided with network data from the American College football network in the football.gml file. Using the principled_clustering function from the cdlib library, your objective is to perform community detection to identify 4 distinct communities within the network. Additionally, you are requested to generate and print a JSON object representing the detected communities.
### Response:
import networkx as nx
from cdlib import algorithms

# Load American College football network
G = nx.read_gml('football.gml')

# Detect communities using the Principled Clustering algorithm
communities = algorithms.principled_clustering(G, 4)

# Convert communities to JSON format
communities_json = communities.to_json()
print(communities_json)
<|EOT|>
