码迷,mamicode.com
首页 > 数据库 > 详细

使用Go处理SDK返回的嵌套层级数据并将所需字段存入数据库(一)

时间:2020-10-30 12:11:28      阅读:24      评论:0      收藏:0      [点我收藏+]

标签:结构   nts   close   date   shang   xxxx   rgb   xxxxxx   sub   

前言

  新项目使用Go搭建服务,其中涉及到很多业务数据的构建以及处理的逻辑,笔者也是刚刚开始写Go代码,刚刚开始的时候必然会踩很多坑,这里就记录一下笔者在处理SDK返回的层级数据时遇到的问题以及后续的优化处理。

业务需求描述

  从某平台获取到的HTTP原始数据格式如下所示:

技术图片
{
    "request_status": "SUCCESS",
    "request_id": "xxxxxx",
    "paging": {},
    "adaccounts": [
        {
            "sub_request_status": "SUCCESS",
            "adaccount": {
                "id": "06585df8-81a5-4010-b3b5-8d718d0c4487",
                "updated_at": "2020-10-28T22:09:24.409Z",
                "created_at": "2020-08-21T11:00:28.455Z",
                "name": "Fashowtime_05_Muyou_EC_SINO_B",
                "type": "PARTNER",
                "status": "ACTIVE",
                "organization_id": "16412453-e008-4353-a8da-881ed5170e9c",
                "funding_source_ids": [
                    "fc7cb056-453a-4b3f-8294-bcaffc5ee1fb"
                ],
                "currency": "USD",
                "timezone": "Asia/Shanghai",
            }
        },
        {
            "sub_request_status": "SUCCESS",
            "adaccount": {
                "id": "0f9542e9-56bd-4fae-a6a9-5b9bd48004a6",
                "updated_at": "2020-10-28T21:50:52.923Z",
                "created_at": "2020-08-21T10:59:07.409Z",
                "name": "Fashowtime_03_Muyou_EC_SINO_B",
                "type": "PARTNER",
                "status": "ACTIVE",
                "organization_id": "16412453-e008-4353-a8da-881ed5170e9c",
                "funding_source_ids": [
                    "8b94cfc2-5932-49c8-8865-e4f33a2bad0c",
                    "fc7cb056-453a-4b3f-8294-bcaffc5ee1fb"
                ],
                "currency": "USD",
                "timezone": "Asia/Shanghai",
            }
        },
        {
            "sub_request_status": "SUCCESS",
            "adaccount": {
                "id": "47ea8129-d1e0-4fa3-8df8-e9cab4a64e7b",
                "updated_at": "2020-10-28T21:57:05.953Z",
                "created_at": "2020-08-21T10:57:34.614Z",
                "name": "Fashowtime_01_Muyou_EC_SINO_B",
                "type": "PARTNER",
                "status": "ACTIVE",
                "organization_id": "16412453-e008-4353-a8da-881ed5170e9c",
                "funding_source_ids": [
                    "fc7cb056-453a-4b3f-8294-bcaffc5ee1fb"
                ],
                "currency": "USD",
                "timezone": "Asia/Shanghai",
            }
        },
        {
            "sub_request_status": "SUCCESS",
            "adaccount": {
                "id": "489ece86-ed2a-4b2f-a697-b470c5f12652",
                "updated_at": "2020-10-28T21:56:38.374Z",
                "created_at": "2020-08-21T10:58:35.585Z",
                "name": "Fashowtime_02_Muyou_EC_SINO_B",
                "type": "PARTNER",
                "status": "ACTIVE",
                "organization_id": "16412453-e008-4353-a8da-881ed5170e9c",
                "funding_source_ids": [
                    "fc7cb056-453a-4b3f-8294-bcaffc5ee1fb"
                ],
                "currency": "USD",
                "timezone": "Asia/Shanghai",
            }
        },
        {
            "sub_request_status": "SUCCESS",
            "adaccount": {
                "id": "fa52ec27-fe6c-489d-a606-6a6e19c66690",
                "updated_at": "2020-10-28T21:56:34.531Z",
                "created_at": "2020-08-21T10:59:53.850Z",
                "name": "Fashowtime_04_Muyou_EC_SINO_B",
                "type": "PARTNER",
                "status": "ACTIVE",
                "organization_id": "16412453-e008-4353-a8da-881ed5170e9c",
                "funding_source_ids": [
                    "fc7cb056-453a-4b3f-8294-bcaffc5ee1fb"
                ],
                "currency": "USD",
                "timezone": "Asia/Shanghai",
            }
        }
    ]
}
HTTP原始数据结构

 

 

 

123

123

123

使用Go处理SDK返回的嵌套层级数据并将所需字段存入数据库(一)

标签:结构   nts   close   date   shang   xxxx   rgb   xxxxxx   sub   

原文地址:https://www.cnblogs.com/paulwhw/p/13897595.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!