import json


def json_top_atom_count(json_str):
    """Count the number of atoms in a JSON topology used by wepy HDF5."""

    top_d = json.loads(json_str)
    atom_count = 0
    atom_count = 0
    for chain in top_d['chains']:
        for residue in chain['residues']:
            atom_count += len(residue['atoms'])

    return atom_count