Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Custom control over the creation of the resource object.
  • Ability to include the Key ID within the resource object.
  • Ability to identify a part of a Key ID as the resource ID.
  • Lower-level errors can be trapped and handled as desired.
  • The handle to the JSON object is compatible with the SRP_JsonJSON utility function (for even more custom control as needed).

...

Method 3: Using the SRP_Json Utility Function

GetDatabaseItem is an example of a high-level service. That is, it relies upon a simple interface and default behavior. Like other high-level services, GetDatabaseItem is built on top of slightly lower-level services. The most important one of these is GetObject. (which is also a member of the HTTP_Resource_Services module). Let's look at an example of an API that uses the GetObject service to produce the same resource as the GetDatabaseItem service:When complete control at the lowest level is required, you'll want to use SRP_JSON to create your resource. As noted above, the handle returned by the GetObject service is compatible with the SRP_JSON function and vice-versa. Therefore, a developer can choose to start with either method and continue to use both the SRP_JSON services or the higher level GetObject companion services (e.g., AddProperty, AddSubProperty, etc.) at will. One unique feature of SRP_JSON is its ability to interrogate the resource object using services like GetValue. This is useful when a resource object is generated elsewhere. For instance, let's assume that a resource object was created by another service and it returns a handle. The calling routine now needs to modify this resource object, but only if it has specific data already in it. The GetObject companion services can only update resource objects, not inspect them. This requires the assistance of one or more of the SRP_JSON member services.

Code Block
languagebp