应用与数据集成平台 ROMA CONNECT-数据映射:源端-数据格式为JSON样例
源端-数据格式为JSON样例
当源端数据源的类型为“JSON”时,在使用数据映射时选择数据格式“JSON”,将源端数据源的输出作为源端数据源页签中“导入文件”的输入,根据文件的编码格式格式选择导入文件编码,可选项有GB2312、UTF-8和ASCII。此时源端数据源页签中会根据导入的文件内容自动生成相应的字段。
目的端数据格式选择“MySQL”,在选择表名后,目的端数据源页签会自动生成数据库表中的字段。
以下面的组合应用为例,该组合应用的主要功能是调用Open API获取OBS指定桶的对象列表,并将结果中的桶名称和对象名称通过数据映射,映射到MySql指定表中的相关字段,然后使用MySql添加记录的操作将桶名和对象名存储到MySql中。其中, 对象存储服务 OBS产生的结果是数据映射的源端数据源,MySql是目的端数据源。可以通过使用Open API调用OBS连接器执行获取桶内对象列表的操作结果获得远端数据源的导入文件。也可以根据OBS连接器执行获取桶内对象列表的操作结果手动添加字段信息。
源端导入的文件内容:
{
"responseHeaders": {
"bucket-location": "cn-north-7",
"connection": "keep-alive",
"content-length": "504",
"content-type": "application/xml",
"date": "2024-04-24T07:07:43.000+00:00",
"id-2": "32AAAQAAEAABAAAQAAEAABAAAQAAEAA BCS bOSbK ncLEgZnxffa8vFPuDgVIt7n9",
"request-id": "0000018F0EEE84734012ACF15A46395E",
"server": "OBS"
},
"originalHeaders": {
"connection": "keep-alive",
"content-length": "504",
"content-type": "application/xml",
"date": "Wed, 24 Apr 2024 07:07:43 GMT",
"server": "OBS",
"x-obs-bucket-location": "cn-north-7",
"x-obs-id-2": "32AAAQAAEAABAAAQAAEAABAAAQAAEAAB CS bOSbK+ncLEgZnxffa8vFPuDgVIt7n9",
"x-obs-request-id": "0000018F0EEE84734012ACF15A46395E"
},
"statusCode": 200,
"objectSummaries": [
{
"bucketName": "test0223",
"objectKey": "test0424.txt",
"owner": {
"displayName": null,
"id": "0ab78f256080d2890feac0086234d7c0"
},
"metadata": {
"responseHeaders": {},
"originalHeaders": {},
"statusCode": 0,
"lastModified": "2024-04-24T06:51:46.566+00:00",
"contentLength": 19,
"contentType": null,
"contentEncoding": null,
"contentDisposition": null,
"cacheControl": null,
"contentLanguage": null,
"expires": null,
"etag": "\"0b26e313ed4a7ca6904b0e9369e5b957\"",
"contentMd5": null,
"crc64": null,
"storageClass": "STANDARD",
"webSiteRedirectLocation": null,
"nextPosition": -1,
"appendable": false,
"objectStorageClass": "STANDARD",
"allMetadata": {},
"metadata": {},
"requestId": ""
},
"objectContent": null
}
],
"commonPrefixes": [],
"extendCommonPrefixes": [],
"bucketName": "test0223",
"truncated": false,
"prefix": "",
"marker": "",
"maxKeys": 1000,
"delimiter": null,
"nextMarker": null,
"location": "cn-north-7",
"extenedCommonPrefixes": [],
"objects": [
{
"bucketName": "test0223",
"objectKey": "test0424.txt",
"owner": {
"displayName": null,
"id": "0ab78f256080d2890feac0086234d7c0"
},
"metadata": {
"responseHeaders": {},
"originalHeaders": {},
"statusCode": 0,
"lastModified": "2024-04-24T06:51:46.566+00:00",
"contentLength": 19,
"contentType": null,
"contentEncoding": null,
"contentDisposition": null,
"cacheControl": null,
"contentLanguage": null,
"expires": null,
"etag": "\"0b26e313ed4a7ca6904b0e9369e5b957\"",
"contentMd5": null,
"crc64": null,
"storageClass": "STANDARD",
"webSiteRedirectLocation": null,
"nextPosition": -1,
"appendable": false,
"objectStorageClass": "STANDARD",
"allMetadata": {},
"metadata": {},
"requestId": ""
},
"objectContent": null
}
],
"requestId": "0000018F0EEE84734012ACF15A46395E"
}
数据映射输出结果为: