此函数提供一个租约中直至其端点的所有隔间。此处myobject的类型为<;“oci.identity.MODULES.CAY.CAY”类>;如何将其转换为json?这是哪种类型的?在使用json.dumps()时,它显示类型隔间不可json序列化
'''
import oci
import hashlib
import uuid
import json
global finale_response,tenant_id,profile
profile="abc-profile"
tenant_id = "ocid1.tenancy.oc1.."
finale_response = []
config = oci.config.from_file(profile_name=profile)
def get_compartments(id):
identity_client = oci.identity.IdentityClient(config)
list_compartments_response = identity_client.list_compartments(compartment_id=id)
response = list_compartments_response.data
if response != []:
child_compartment_list = []
for i in range(len(response)):
compartmentId = response[i].id
myobject= response[i]
print(type(myobject))
finale_response.append({"profileName":profile,
"compartmentId":compartmentId,
"tenantId": tenant_id,
"comMetadata":myobject})
child_compartment_list.append(compartmentId)
for id in child_compartment_list:
get_compartments(id)
return finale_response
myList = get_compartments(tenant_id)
print(myList)
print(type(myList))
'''
有关如何获取Json响应的示例,请参阅:https://github.com/oracle/oci-python-sdk/blob/master/examples/json_response_example.py
请检查此页面此页面,这可能很有用[使用cJSON创建JSON字符串][1]
谢谢 阿努帕姆
[1]:https://www.programmersought.com/article/49402068665/#:~:text=charcJSON\u打印(cJSON%20项,属于%20此%20对象%20到%20
相关问题 更多 >
编程相关推荐