1

我正在尝试使用 TRESTResponseDataSetAdapter。

我为 JSON RootElement 属性尝试的每个组合都失败了

您可以通过在浏览器中运行它来查看内容:

https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=Demo&count=1000

{
   "contacts":[
      {
         "addedAt":1405347851360,
         "vid":154835,
         "canonical-vid":154835,
         "merged-vids":[

         ],
         "portal-id":62515,
         "is-contact":true,
         "profile-token":"AO_T-mMn77ArlMSBCTdpOp0rf0qYYooZ7bHB6ehvufx9uNoV0Pyuiq1wq-A83BQmzFVFVC45T8S6tXhkq_7fcDi5Wzne7VXydwTvrKIViisZNBjWhUjJ8OiXhXW0owESlE2QCh2_rZsy",
         "profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMn77ArlMSBCTdpOp0rf0qYYooZ7bHB6ehvufx9uNoV0Pyuiq1wq-A83BQmzFVFVC45T8S6tXhkq_7fcDi5Wzne7VXydwTvrKIViisZNBjWhUjJ8OiXhXW0owESlE2QCh2_rZsy/",
         "properties":{
            "firstname":{
               "value":"HubSpot"
            },
            "lastmodifieddate":{
               "value":"1429569233340"
            },
            "lastname":{
               "value":"Test"
            }
         },
         "form-submissions":[
            {
               "conversion-id":"b18f9fd8-b8d3-49e5-898a-ac301fac93e9",
               "timestamp":1405347851180,
               "form-id":"b844ad5e-32bd-41e1-b0e6-ed990c5f3d1b",
               "portal-id":62515,
               "page-url":"http://demo.hubapi.com/your-stunning-headline-30",
               "page-title":"Your stunning headline!",
               "page-id":"324527",
               "title":"My New Form",
               "meta-data":[

               ]
            }
         ],
         "identity-profiles":[
            {
               "vid":154835,
               "saved-at-timestamp":1405347851237,
               "deleted-changed-timestamp":0,
               "identities":[
                  {
                     "type":"EMAIL",
                     "value":"test@hubspot.com",
                     "timestamp":1405347851180
                  },
                  {
                     "type":"LEAD_GUID",
                     "value":"c8f20860-d3d6-4b57-b092-86a07cebdcbc",
                     "timestamp":1405347851237
                  }
               ]
            }
         ],
         "merge-audits":[

         ]
      },
      {
         "addedAt":1390569372731,
         "vid":196181,
         "canonical-vid":196181,
         "merged-vids":[

         ],
         "portal-id":62515,
         "is-contact":true,
         "profile-token":"AO_T-mNWKZQBRv0UiQpPnG-WPBgVlfYwFgdTyJW3sU9frlA4esRYMOtMpo4OQMh736HGvJpuDLAuJexFXkyrIPu7eK-hxFYwGoqefbbP1cQeh6B0mRPE-iU1dhYRhRJsWyroaToFvFuo",
         "profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mNWKZQBRv0UiQpPnG-WPBgVlfYwFgdTyJW3sU9frlA4esRYMOtMpo4OQMh736HGvJpuDLAuJexFXkyrIPu7eK-hxFYwGoqefbbP1cQeh6B0mRPE-iU1dhYRhRJsWyroaToFvFuo/",
         "properties":{
            "firstname":{
               "value":"Charles"
            },
            "lastmodifieddate":{
               "value":"1429569231725"
            },
            "company":{
               "value":""
            },
            "lastname":{
               "value":"Gowland"
            }
         },
         "form-submissions":[

         ],
         "identity-profiles":[
            {
               "vid":196181,
               "saved-at-timestamp":1390569372649,
               "deleted-changed-timestamp":0,
               "identities":[
                  {
                     "type":"EMAIL",
                     "value":"clg@gburnette.com",
                     "timestamp":1390568711002
                  },
                  {
                     "type":"LEAD_GUID",
                     "value":"dca0d8a2-fa9c-4ca6-b5ef-c1bfb4a0bed4",
                     "timestamp":1390569372636
                  }
               ]
            }
         ],
         "merge-audits":[

         ]
      },
      {
         "addedAt":1390569372834,
         "vid":196182,
         "canonical-vid":196182,
         "merged-vids":[

         ],
         "portal-id":62515,
         "is-contact":true,
         "profile-token":"AO_T-mPTJ_EIS2780cJONDGKv5bmchukJnQ37QmmSc-lPJacEyzXo8piybhaAhQzT0HBXxq0QYXFU_4wN5ewYsclTt8WE3KAxx6neusNNYGr8aEiy-s6izAG-CCehTdomM5Pai4YOKue",
         "profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPTJ_EIS2780cJONDGKv5bmchukJnQ37QmmSc-lPJacEyzXo8piybhaAhQzT0HBXxq0QYXFU_4wN5ewYsclTt8WE3KAxx6neusNNYGr8aEiy-s6izAG-CCehTdomM5Pai4YOKue/",
         "properties":{
            "firstname":{
               "value":"Curtis"
            },
            "lastmodifieddate":{
               "value":"1429569238098"
            },
            "company":{
               "value":""
            },
            "lastname":{
               "value":"Romig"
            }
         },
         "form-submissions":[

         ],
         "identity-profiles":[
            {
               "vid":196182,
               "saved-at-timestamp":1390569372699,
               "deleted-changed-timestamp":0,
               "identities":[
                  {
                     "type":"EMAIL",
                     "value":"curtis.romig@bryancave.com",
                     "timestamp":1390568725415
                  },
                  {
                     "type":"LEAD_GUID",
                     "value":"e18dc184-0238-48f1-a8a2-4476733f50d3",
                     "timestamp":1390569372641
                  }
               ]
            }
         ],
         "merge-audits":[

         ]
      },
      {
         "addedAt":1390569372757,
         "vid":196183,
         "canonical-vid":196183,
         "merged-vids":[

         ],
         "portal-id":62515,
         "is-contact":true,
         "profile-token":"AO_T-mOq49asR9pF4P9paqXhVApLjs9CXDFqCFs4BL7Y5z7TRYRoSC9i8cXxGOdXZqC-3D1doXT5G-pmAG283AFo0BYY3D-1AV2VhwIlVZ3t1KF-6G7DBQw80lRqBjPbJhtLnY7U6rd-",
         "profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mOq49asR9pF4P9paqXhVApLjs9CXDFqCFs4BL7Y5z7TRYRoSC9i8cXxGOdXZqC-3D1doXT5G-pmAG283AFo0BYY3D-1AV2VhwIlVZ3t1KF-6G7DBQw80lRqBjPbJhtLnY7U6rd-/",
         "properties":{
            "firstname":{
               "value":"Eugene"
            },
            "lastmodifieddate":{
               "value":"1429569256338"
            },
            "company":{
               "value":""
            },
            "lastname":{
               "value":"Klibanoff"
            }
         },
         "form-submissions":[

         ],
         "identity-profiles":[
            {
               "vid":196183,
               "saved-at-timestamp":1390569372682,
               "deleted-changed-timestamp":0,
               "identities":[
                  {
                     "type":"EMAIL",
                     "value":"eklibanoff@incomm.com",
                     "timestamp":1390568722786
                  },
                  {
                     "type":"LEAD_GUID",
                     "value":"276f1a0f-ce8f-4069-9b7a-405f9e14971a",
                     "timestamp":1390569372674
                  }
               ]
            }
         ],
         "merge-audits":[

         ]
      },
      {
         "addedAt":1390569372800,
         "vid":196184,
         "canonical-vid":196184,
         "merged-vids":[

         ],
         "portal-id":62515,
         "is-contact":true,
         "profile-token":"AO_T-mMay6vd3gbNXXOGGn7WYa4332kjWEY6hYvggd98z-MYeHHaXL8BqAHSmsGQ1VVuN9_JOUPlqQ5ZC4e0-fNjOqj-yNp23nsqldKBYY0WF-m5pgnOGEwXEV2eLNVJmFffQ0U3SXXL",
         "profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMay6vd3gbNXXOGGn7WYa4332kjWEY6hYvggd98z-MYeHHaXL8BqAHSmsGQ1VVuN9_JOUPlqQ5ZC4e0-fNjOqj-yNp23nsqldKBYY0WF-m5pgnOGEwXEV2eLNVJmFffQ0U3SXXL/",
         "properties":{
            "firstname":{
               "value":"James C. & Brenda L."
            },
            "lastmodifieddate":{
               "value":"1429569255451"
            },
            "company":{
               "value":""
            },
            "lastname":{
               "value":"Kellling"
            }
         },
         "form-submissions":[

         ],
         "identity-profiles":[
            {
               "vid":196184,
               "saved-at-timestamp":1390569372744,
               "deleted-changed-timestamp":0,
               "identities":[
                  {
                     "type":"EMAIL",
                     "value":"jameskelling@bellsouth.net",
                     "timestamp":1390568911277
                  },
                  {
                     "type":"LEAD_GUID",
                     "value":"4b92ccc6-d777-4e3e-90d9-bc4722329c16",
                     "timestamp":1390569372738
                  }
               ]
            }
         ],
         "merge-audits":[

         ]
      }
   ],
   "has-more":true,
   "vid-offset":196184
}

我正在尝试构建一个包含 Company、FirstName、LastName 和 EMAIL 的 ClientDataSet

有人可以查看内容并为我识别正确的 RootElement 吗?

4

1 回答 1

3

这种数据结构没有即插即用的TClientDataSet方式来映射到.

映射可以通过这样TRESTResponseDataSetAdapter的对象数组来完成

[
  {
    "firstname": "John",
    "lastname": "Doe",
    "email": "john@doe.com"
  },
  {
    "firstname": "Jane",
    "lastname": "Doe",
    "email": "jane@doe.com"
  }
]

甚至嵌套

{
  "contacts": [
    {
      "firstname": "John",
      "lastname": "Doe",
      "email": "john@doe.com"
    },
    {
      "firstname": "Jane",
      "lastname": "Doe",
      "email": "jane@doe.com"
    }
  ]
}

当您将RootElement属性设置为contacts.

但是,您从 REST API 获得的这种嵌套结构却不是这样。

您必须手动了解结构和映射

于 2015-04-26T08:21:36.933 回答