展平嵌套 JSON?
Flatten a nested JSON?
我正在尝试展平以下 JSON 并分层展平它:
https://justpaste.it/6e60p
我正在使用 pandas json_normalize
函数来执行此操作,但我有点卡住了。
pd.json_normalize(test_json['result'])
给我 2 列嵌套的字典。
我正在尝试使用 record_path=['userDetails']
但它只打开用户部分。
请告知什么是分层扁平化 JSON 的最佳做法?
test_json = {
"success": True,
"error": 'null',
"errorObject": None,
"result": [
{
"requestId": 45,
"userIds": [
4
],
"userDetails": [
{
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
],
"requestColumnGrants": [
{
"id": 57,
"creationTime": 1652083406187,
"lastUpdateTime": 1652083407853,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 1,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "nationkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "nationkey",
"description": None,
"tags": [
{
"id": 1,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "pii",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 0,
"ordinalOverride": None
},
"operationType": "FULL_MASKING",
"operationPayload": "{\"letter\":\"*\"}",
"policyRecommendedOperationType": "FULL_MASKING",
"policyRecommendedOperationPayload": "{\"letter\":\"*\"}",
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 56,
"creationTime": 1652083406165,
"lastUpdateTime": 1652083406165,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 2,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "name",
"rawType": "STRING",
"type": "UNKNOWN",
"trinoName": "name",
"description": None,
"tags": [
{
"id": 2,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "first_name",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 1,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 55,
"creationTime": 1652083406141,
"lastUpdateTime": 1652083406141,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 3,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "regionkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "regionkey",
"description": None,
"tags": [
{
"id": 5,
"creationTime": 1652080042000,
"lastUpdateTime": 1652080042000,
"name": "region",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 2,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
}
],
"workflowValues": [
{
"requestId": 45,
"requestWorkflowProgressionId": 106,
"name": "f3624cb8-cebd-4608-9d9a-60c5b21adbd3.firstName",
"value": "dcasd",
"type": "String",
"source": "Form",
"id": 1,
"creationTime": 1652083422000,
"lastUpdateTime": 1652083422000
},
{
"requestId": 45,
"requestWorkflowProgressionId": 106,
"name": "f3624cb8-cebd-4608-9d9a-60c5b21adbd3.lastNam",
"value": "dsadw",
"type": "String",
"source": "Form",
"id": 2,
"creationTime": 1652083422000,
"lastUpdateTime": 1652083422000
}
]
},
{
"requestId": 44,
"userIds": [
4
],
"userDetails": [
{
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
],
"requestColumnGrants": [
{
"id": 54,
"creationTime": 1652082684949,
"lastUpdateTime": 1652082686821,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 1,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "nationkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "nationkey",
"description": None,
"tags": [
{
"id": 1,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "pii",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 0,
"ordinalOverride": None
},
"operationType": "FULL_MASKING",
"operationPayload": "{\"letter\":\"*\"}",
"policyRecommendedOperationType": "FULL_MASKING",
"policyRecommendedOperationPayload": "{\"letter\":\"*\"}",
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 53,
"creationTime": 1652082684927,
"lastUpdateTime": 1652082684927,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 2,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "name",
"rawType": "STRING",
"type": "UNKNOWN",
"trinoName": "name",
"description": None,
"tags": [
{
"id": 2,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "first_name",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 1,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 52,
"creationTime": 1652082684905,
"lastUpdateTime": 1652082684905,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 3,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "regionkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "regionkey",
"description": None,
"tags": [
{
"id": 5,
"creationTime": 1652080042000,
"lastUpdateTime": 1652080042000,
"name": "region",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 2,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
}
],
"workflowValues": []
},
{
"requestId": 40,
"userIds": [
4
],
"userDetails": [
{
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
],
"requestColumnGrants": [
{
"id": 42,
"creationTime": 1651412063835,
"lastUpdateTime": 1651412065727,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 1,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "nationkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "nationkey",
"description": None,
"tags": [
{
"id": 1,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "pii",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 0,
"ordinalOverride": None
},
"operationType": "FULL_MASKING",
"operationPayload": "{\"letter\":\"*\"}",
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 41,
"creationTime": 1651412063807,
"lastUpdateTime": 1651412063807,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 2,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "name",
"rawType": "STRING",
"type": "UNKNOWN",
"trinoName": "name",
"description": None,
"tags": [
{
"id": 2,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "first_name",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 1,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 40,
"creationTime": 1651412063779,
"lastUpdateTime": 1651412063779,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 3,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "regionkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "regionkey",
"description": None,
"tags": [
{
"id": 5,
"creationTime": 1652080042000,
"lastUpdateTime": 1652080042000,
"name": "region",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 2,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
}
],
"workflowValues": []
},
{
"requestId": 39,
"userIds": [
4
],
"userDetails": [
{
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
],
"requestColumnGrants": [
{
"id": 39,
"creationTime": 1651411857024,
"lastUpdateTime": 1651411858669,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 1,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "nationkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "nationkey",
"description": None,
"tags": [
{
"id": 1,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "pii",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 0,
"ordinalOverride": None
},
"operationType": "FULL_MASKING",
"operationPayload": "{\"letter\":\"*\"}",
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 38,
"creationTime": 1651411856994,
"lastUpdateTime": 1651411856994,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 2,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "name",
"rawType": "STRING",
"type": "UNKNOWN",
"trinoName": "name",
"description": None,
"tags": [
{
"id": 2,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "first_name",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 1,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 37,
"creationTime": 1651411856970,
"lastUpdateTime": 1651411856970,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 3,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "regionkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "regionkey",
"description": None,
"tags": [
{
"id": 5,
"creationTime": 1652080042000,
"lastUpdateTime": 1652080042000,
"name": "region",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 2,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
}
],
"workflowValues": []
},
{
"requestId": 38,
"userIds": [
4
],
"userDetails": [
{
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
],
"requestColumnGrants": [
{
"id": 36,
"creationTime": 1651411738066,
"lastUpdateTime": 1651411739933,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 1,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "nationkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "nationkey",
"description": None,
"tags": [
{
"id": 1,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "pii",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 0,
"ordinalOverride": None
},
"operationType": "FULL_MASKING",
"operationPayload": "{\"letter\":\"*\"}",
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 35,
"creationTime": 1651411738036,
"lastUpdateTime": 1651411738036,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 2,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "name",
"rawType": "STRING",
"type": "UNKNOWN",
"trinoName": "name",
"description": None,
"tags": [
{
"id": 2,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "first_name",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 1,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 34,
"creationTime": 1651411738012,
"lastUpdateTime": 1651411738013,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 3,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "regionkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "regionkey",
"description": None,
"tags": [
{
"id": 5,
"creationTime": 1652080042000,
"lastUpdateTime": 1652080042000,
"name": "region",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 2,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
}
],
"workflowValues": []
}
],
"paging": {
"start": 0,
"limit": 20,
"total": 5,
"hasMore": False
}
}
flatten_json 现在是一个图书馆,所以你可以这样做。它会给你 160 列
from flatten_json import flatten
dic_flattened = (flatten(d, '.') for d in test_json['result'])
df = pd.DataFrame(dic_flattened)
df.shape
(5, 160)
我正在尝试展平以下 JSON 并分层展平它: https://justpaste.it/6e60p
我正在使用 pandas json_normalize
函数来执行此操作,但我有点卡住了。
pd.json_normalize(test_json['result'])
给我 2 列嵌套的字典。
我正在尝试使用 record_path=['userDetails']
但它只打开用户部分。
请告知什么是分层扁平化 JSON 的最佳做法?
test_json = {
"success": True,
"error": 'null',
"errorObject": None,
"result": [
{
"requestId": 45,
"userIds": [
4
],
"userDetails": [
{
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
],
"requestColumnGrants": [
{
"id": 57,
"creationTime": 1652083406187,
"lastUpdateTime": 1652083407853,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 1,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "nationkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "nationkey",
"description": None,
"tags": [
{
"id": 1,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "pii",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 0,
"ordinalOverride": None
},
"operationType": "FULL_MASKING",
"operationPayload": "{\"letter\":\"*\"}",
"policyRecommendedOperationType": "FULL_MASKING",
"policyRecommendedOperationPayload": "{\"letter\":\"*\"}",
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 56,
"creationTime": 1652083406165,
"lastUpdateTime": 1652083406165,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 2,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "name",
"rawType": "STRING",
"type": "UNKNOWN",
"trinoName": "name",
"description": None,
"tags": [
{
"id": 2,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "first_name",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 1,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 55,
"creationTime": 1652083406141,
"lastUpdateTime": 1652083406141,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 3,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "regionkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "regionkey",
"description": None,
"tags": [
{
"id": 5,
"creationTime": 1652080042000,
"lastUpdateTime": 1652080042000,
"name": "region",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 2,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
}
],
"workflowValues": [
{
"requestId": 45,
"requestWorkflowProgressionId": 106,
"name": "f3624cb8-cebd-4608-9d9a-60c5b21adbd3.firstName",
"value": "dcasd",
"type": "String",
"source": "Form",
"id": 1,
"creationTime": 1652083422000,
"lastUpdateTime": 1652083422000
},
{
"requestId": 45,
"requestWorkflowProgressionId": 106,
"name": "f3624cb8-cebd-4608-9d9a-60c5b21adbd3.lastNam",
"value": "dsadw",
"type": "String",
"source": "Form",
"id": 2,
"creationTime": 1652083422000,
"lastUpdateTime": 1652083422000
}
]
},
{
"requestId": 44,
"userIds": [
4
],
"userDetails": [
{
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
],
"requestColumnGrants": [
{
"id": 54,
"creationTime": 1652082684949,
"lastUpdateTime": 1652082686821,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 1,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "nationkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "nationkey",
"description": None,
"tags": [
{
"id": 1,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "pii",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 0,
"ordinalOverride": None
},
"operationType": "FULL_MASKING",
"operationPayload": "{\"letter\":\"*\"}",
"policyRecommendedOperationType": "FULL_MASKING",
"policyRecommendedOperationPayload": "{\"letter\":\"*\"}",
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 53,
"creationTime": 1652082684927,
"lastUpdateTime": 1652082684927,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 2,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "name",
"rawType": "STRING",
"type": "UNKNOWN",
"trinoName": "name",
"description": None,
"tags": [
{
"id": 2,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "first_name",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 1,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 52,
"creationTime": 1652082684905,
"lastUpdateTime": 1652082684905,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 3,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "regionkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "regionkey",
"description": None,
"tags": [
{
"id": 5,
"creationTime": 1652080042000,
"lastUpdateTime": 1652080042000,
"name": "region",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 2,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
}
],
"workflowValues": []
},
{
"requestId": 40,
"userIds": [
4
],
"userDetails": [
{
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
],
"requestColumnGrants": [
{
"id": 42,
"creationTime": 1651412063835,
"lastUpdateTime": 1651412065727,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 1,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "nationkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "nationkey",
"description": None,
"tags": [
{
"id": 1,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "pii",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 0,
"ordinalOverride": None
},
"operationType": "FULL_MASKING",
"operationPayload": "{\"letter\":\"*\"}",
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 41,
"creationTime": 1651412063807,
"lastUpdateTime": 1651412063807,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 2,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "name",
"rawType": "STRING",
"type": "UNKNOWN",
"trinoName": "name",
"description": None,
"tags": [
{
"id": 2,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "first_name",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 1,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 40,
"creationTime": 1651412063779,
"lastUpdateTime": 1651412063779,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 3,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "regionkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "regionkey",
"description": None,
"tags": [
{
"id": 5,
"creationTime": 1652080042000,
"lastUpdateTime": 1652080042000,
"name": "region",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 2,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
}
],
"workflowValues": []
},
{
"requestId": 39,
"userIds": [
4
],
"userDetails": [
{
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
],
"requestColumnGrants": [
{
"id": 39,
"creationTime": 1651411857024,
"lastUpdateTime": 1651411858669,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 1,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "nationkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "nationkey",
"description": None,
"tags": [
{
"id": 1,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "pii",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 0,
"ordinalOverride": None
},
"operationType": "FULL_MASKING",
"operationPayload": "{\"letter\":\"*\"}",
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 38,
"creationTime": 1651411856994,
"lastUpdateTime": 1651411856994,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 2,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "name",
"rawType": "STRING",
"type": "UNKNOWN",
"trinoName": "name",
"description": None,
"tags": [
{
"id": 2,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "first_name",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 1,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 37,
"creationTime": 1651411856970,
"lastUpdateTime": 1651411856970,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 3,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "regionkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "regionkey",
"description": None,
"tags": [
{
"id": 5,
"creationTime": 1652080042000,
"lastUpdateTime": 1652080042000,
"name": "region",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 2,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
}
],
"workflowValues": []
},
{
"requestId": 38,
"userIds": [
4
],
"userDetails": [
{
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
],
"requestColumnGrants": [
{
"id": 36,
"creationTime": 1651411738066,
"lastUpdateTime": 1651411739933,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 1,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "nationkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "nationkey",
"description": None,
"tags": [
{
"id": 1,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "pii",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 0,
"ordinalOverride": None
},
"operationType": "FULL_MASKING",
"operationPayload": "{\"letter\":\"*\"}",
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 35,
"creationTime": 1651411738036,
"lastUpdateTime": 1651411738036,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 2,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "name",
"rawType": "STRING",
"type": "UNKNOWN",
"trinoName": "name",
"description": None,
"tags": [
{
"id": 2,
"creationTime": 1651048111000,
"lastUpdateTime": 1651048111000,
"name": "first_name",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 1,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
},
{
"id": 34,
"creationTime": 1651411738012,
"lastUpdateTime": 1651411738013,
"schemaInfoDetails": {
"id": 1,
"displayName": "adam-test-collibra"
},
"tableInfoDetails": {
"id": 1,
"displayName": "nation"
},
"columnInfoDetails": {
"id": 3,
"creationTime": 1651047171000,
"lastUpdateTime": 1652080042000,
"name": "regionkey",
"rawType": "INT64",
"type": "UNKNOWN",
"trinoName": "regionkey",
"description": None,
"tags": [
{
"id": 5,
"creationTime": 1652080042000,
"lastUpdateTime": 1652080042000,
"name": "region",
"tagLevel": "COLUMN",
"riskFactor": "NONE"
}
],
"ordinal": 2,
"ordinalOverride": None
},
"operationType": "NONE",
"operationPayload": None,
"policyRecommendedOperationType": None,
"policyRecommendedOperationPayload": None,
"riskFactor": "NONE",
"creatorUserId": 4,
"creatorUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
},
"lastUpdateUserId": 4,
"lastUpdateUserDetails": {
"displayName": "Admin Demo",
"profileImageUrl": None,
"roles": [
"ADMIN"
],
"countryIso": "IL",
"id": 4,
"creationTime": 1650970312000,
"lastUpdateTime": 1651046585000
}
}
],
"workflowValues": []
}
],
"paging": {
"start": 0,
"limit": 20,
"total": 5,
"hasMore": False
}
}
flatten_json 现在是一个图书馆,所以你可以这样做。它会给你 160 列
from flatten_json import flatten
dic_flattened = (flatten(d, '.') for d in test_json['result'])
df = pd.DataFrame(dic_flattened)
df.shape
(5, 160)