<｜begin▁of▁sentence｜>### Instruction:
Given the Power grid graph which you can read from a GML file named power.gml, can you use the spectral clustering function in cdlib to perform community detection with a maximum of 2 communities? And can you export the community detection results to a JSON format?
### Response:
import networkx as nx
from cdlib import algorithms

# Read power grid graph from GML file
G = nx.read_gml('power.gml')

# Perform community detection using spectral clustering
communities = algorithms.spectral(G, kmax=2)

# Export community detection results to JSON
communities_json = communities.to_json()

print(communities_json)
<|EOT|>
