如何消除ORDS中的额外参数
我正在使用 sql Developer 和 ORDS 来启用前端来获取数据。在通过 REST 服务返回的数据中,我得到诸如 "hasMore":false,"limit":25,"offset":0,"count":4,"links":
之类 的参数与实际数据。
我怎样才能只获取实际数据?
示例:
{
"items":[
{
"empid":1,
"ename":"hello"
},
{
"empid":3,
"ename":"hello"
},
{
"empid":2,
"ename":"hello"
},
{
"empid":4,
"ename":"hello"
}
],
"hasMore":false,
"limit":0,
"offset":0,
"count":4,
"links":[
{
"rel":"self",
"href":"http://localhost:8081/ords/vinayak/dem/employees/"
},
{
"rel":"describedby",
"href":"http://localhost:8081/ords/vinayak/metadata-catalog/dem/employees/"
}
]
}
这是我得到的输出。但我想要它作为
{
"items":[
{
"empid":1,
"ename":"hello"
},
{
"empid":3,
"ename":"hello"
},
{
"empid":2,
"ename":"hello"
},
{
"empid":4,
"ename":"hello"
}
]
}
I am using sql developer and ORDS to enable a front end to fetch data. In the data returned through the REST service, I am getting parameters like "hasMore":false,"limit":25,"offset":0,"count":4,"links":
along with actual data.
How can I fetch ONLY actual data ?
Example:
{
"items":[
{
"empid":1,
"ename":"hello"
},
{
"empid":3,
"ename":"hello"
},
{
"empid":2,
"ename":"hello"
},
{
"empid":4,
"ename":"hello"
}
],
"hasMore":false,
"limit":0,
"offset":0,
"count":4,
"links":[
{
"rel":"self",
"href":"http://localhost:8081/ords/vinayak/dem/employees/"
},
{
"rel":"describedby",
"href":"http://localhost:8081/ords/vinayak/metadata-catalog/dem/employees/"
}
]
}
This is the output i am getting. But I want it as
{
"items":[
{
"empid":1,
"ename":"hello"
},
{
"empid":3,
"ename":"hello"
},
{
"empid":2,
"ename":"hello"
},
{
"empid":4,
"ename":"hello"
}
]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,您将默认获得查询请求的分页,因为我们不知道您可能获得多少数据。您可以通过将模块的页面大小设置为 0 来关闭它。
当然,现在由您来确保不会因构建和通过网络传递无限大小的 JSON 文档而陷入麻烦。
Generally you're going to get pagination by default for query requests, because we don't know how much data you might be getting. You can turn that off by setting page size to 0 for your module.
But of course, its now up to you to ensure you don't get into troubles with unlimited sized JSON documents being built and passed over the wire.
REST API 本质上是 LINK 驱动的,这是 Oracle REST 数据服务 (ORDS) 背后的核心概念之一。
基本上,您需要用于导航应用程序的链接。
如果您不想要它们,您可以这样做两件事。
1.您可以创建自己的回复。这意味着不使用 ORDS 的内置功能,而是执行一些操作,例如使用处理程序的 MEDIA 源类型,并编写 PL/SQL 或 SQL 代码来构建您希望在调用时返回的 JSON 文档。
示例,但使用 XML 而不是 JSON
2.使用已弃用的源类型
调用此端点,我的响应如下所示 -
已弃用意味着我们已告诉您我们不打算支持此功能永远。该功能可能会在未来版本中消失。
并不是说教,但如果您有大量记录,您将需要分页,然后您将需要这些链接。您的 javascript 应用程序/框架/任何内容都应该足够灵活,可以忽略您不喜欢使用的 json 属性和链接。
免责声明:我是 Oracle 的产品经理,ORDS 是我的产品之一。
REST APIs are by nature LINK driven, this is one of the core concepts behind Oracle REST Data Services (ORDS).
Basically, you want links to navigate with for your apps.
If you don't want them, you can do two things.
1.You can create your own responses. That would mean not using the built-in features of ORDS and instead doing something like using the MEDIA source type for your handler, and writing PL/SQL or SQL code that builds the JSON document you want returned on the call.
Example but with XML instead of JSON
2.Use a deprecated source type
Calling this endpoint, my response looks like this -
Deprecated means we've told you we don't plan to support this forever. The feature could go away in a future release.
And not to be preachy, but if you have lots of records, you'll want paging, and then you're going to want those links. Your javascript apps / frameworks / whatever should be flexible enough to ignore the json attributes and links you don't care to use.
Disclaimer: I'm a product manager at Oracle, and ORDS is one of my products.