'How to eliminate the extra parameters from ORDS

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"
      }
   ]
}


Solution 1:[1]

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.

Solution 2:[2]

REST APIs are by nature LINK driven, this is one of the core concepts behind Oracle REST Data Services (ORDS).

The concept is known as HATEOAS (Hypermedia as the Engine of Application State) is a constraint of the REST application architecture. HATEOAS keeps the REST style architecture unique from most other network application architectures.

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

ORDS.DEFINE_HANDLER(
      p_module_name    => 'nolinks',
      p_pattern        => 'emps/',
      p_method         => 'GET',
      p_source_type    => 'json/query;type=feed',
      p_items_per_page =>  0,
      p_mimes_allowed  => '',
      p_comments       => NULL,
      p_source         => 
'select * from locations'
      );

Calling this endpoint, my response looks like this -

enter image description here

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Connor McDonald
Solution 2 thatjeffsmith