Web Connection
REST Return Format Question
Gravatar is a globally recognized avatar based on your email address. REST Return Format Question
  Steve
  All
  Feb 6, 2026 @ 07:13am

Hi Rick,
Just wondering if there is a general rule of thumb (best practice) regarding which format to use when returning a JSON response for data? I see there are at least 3 options:

  1. A cursor, RETURN "cursor:cursorName"
  2. A collection via CursorToCollection()
  3. An Object via SCATTER Name

I guess SCATTER Name only gets the current record, so that can be used when only returning a single record. However, I am typically using the RETURN "cursor:cursorName" approach. Since it all gets converted to JSON, are there circumstances where one is better or more efficient that the others?

TIA,
Steve

Gravatar is a globally recognized avatar based on your email address. re: REST Return Format Question
  Rick Strahl
  Steve
  Feb 6, 2026 @ 10:59am

Steve,

There should be never a need to use CursorToCollection() to return a result from a REST operation, since the cursor:cursorName syntax basically does that behind the scenes but it does so directly off the cursor so it's faster. The explicit method exists if your converting to JSON in some other context where you actually need to get the JSON string.

Object vs. Array result - obviously it depends on what you need to return.

As a matter of style - if your API expects a single record result, don't return a collection of 1 item, but return just the item. So Scatter Name or use a business object or object construction to create that single object to return.

If the result can produce multiple records and it happens to produce a result that only returns 1 item (like a search operation for example), the return the array/collection/cursor.

IOW it depends on what the expected result of the API call is.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: REST Return Format Question
  Steve
  Rick Strahl
  Feb 9, 2026 @ 03:50pm

Thanks for the feedback!

© 1996-2026