getValueAsJSONPatchIfAvailable method

String? getValueAsJSONPatchIfAvailable(
  1. String fieldName
)

Inquiry method that gets the difference between the new value and the previous one as a JSON Patch structure, provided that the Server has used the JSON Patch format to send this difference, as part of the "delta delivery" mechanism.

This, in turn, requires that:

  • the Data Adapter has explicitly indicated JSON Patch as the privileged type of compression for this field;
  • both the previous and new value are suitable for the JSON Patch computation (i.e. they are valid JSON representations);
  • the item was subscribed to in MERGE or DISTINCT mode (note that, in case of two-level behavior, this holds for all fields related with second-level items, as these items are in MERGE mode);
  • sending the JSON Patch difference has been evaluated by the Server as more efficient than sending the full new value.
Note that the last condition can be enforced by leveraging the Server's <jsonpatch_min_length> configuration flag, so that the availability of the JSON Patch form would only depend on the Client and the Data Adapter.
When the above conditions are not met, the method just returns null; in this case, the new value can only be determined through [ItemUpdate.getValue]. For instance, this will always be needed to get the first value received.

Throws IllegalArgumentException if the specified field is not part of the Subscription.

  • fieldName The field name as specified within the "Field List".

Returns A JSON Patch structure representing the difference between the new value and the previous one, or null if the difference in JSON Patch format is not available for any reason.

Implementation

String? getValueAsJSONPatchIfAvailable(String fieldName) {
  return _jsonFields[fieldName];
}