如果你已经有了一个 JSON 对象(而不是字符串),你可以直接使用 len() 函数来求数组的长度:

json_array = [{"a": 1}, {"b": 2}]
print(len(json_array)) # 输出 2
        Python