import json
json.dumps(json.loads(
    """
{"node0":{
    "node1":{
        "attr0":"foo",
        "attr1":"foo bar",
        "attr2":"value with        long        spaces"
    }
}}
"""
    ))
Crunching json with python