0

我在 usergrid 上创建了一个实体,但我发现 usergrid 在 JSON 中添加了额外的数据,我真的不想出现在 API 层中。例如,这是我的实体:

{
  **"uuid": "7cd5c98a-7b16-11e4-9085-b5397738dcd5",
  "type": "summaries",
  "created": 1417629724184,
  "modified": 1417629993800,**
  "accountId": "123123",
  "accounts": [
    {
      "id": "123123",
      "type": "Individual",
      "category": "Prepaid",

uuid/type/created/modified 字段不是我想要提取的,尽管 usergrid 将其添加。我可以在接收端编写逻辑来解析它,但我们不想在代理中编写任何类型的业务逻辑。我怎样才能抑制这种行为?

4

1 回答 1

0

不幸的是,Usergrid 并不适合开放 API,您应该将它放在像 Apigee Edige 这样的管理层之后。登录您的 Apigee 帐户,然后点击创建和管理 API。

在那里,您可以通过提取块或单个元素来操纵 JSON 有效负载(如下所示,我获取所有帐户或仅获取列表中第一个帐户的 ID)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Account-Response">
    <DisplayName>Extract Account Response</DisplayName>
    <FaultRules/>
    <Properties/>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <JSONPayload>
        <Variable name="allComments">
            <JSONPath>$.accounts</JSONPath>
        </Variable>
        <Variable name="account0">
            <JSONPath>$.accounts[0].id</JSONPath>
        </Variable>
    </JSONPayload>
    <Source clearPayload="false">commentResponse</Source>
</ExtractVariables>

如果您不使用 Apigee,您仍然需要在 Usergrid 前面放置某种程序化外观来操作响应。

于 2014-12-03T19:52:23.847 回答