Interface IPartialJSON
- Namespace
- PushTechnology.ClientInterface.Client.Features
- Assembly
- Diffusion.Client.dll
A constraint requiring the current value of a JSON topic to match the partially described value.
public interface IPartialJSON : IUpdateConstraint
- Inherited Members
Remarks
The code:
var factory = Diffusion.UpdateConstraints;
var constraint =
factory.JSONValue
.With("/id", idValue)
.Without("/cancellation");
creates a constraint for a JSON object with a specific ID value and no value for a "cancellation" property.
Missing keys are matched differently to keys that are present with null values.
Methods
With<TValue>(string, UpdateConstraintOperator, TValue)
Compares a location within the JSON topic value to a specified value.
IPartialJSON With<TValue>(string pointer, UpdateConstraintOperator updateConstraintOperator, TValue value)
Parameters
pointerstringThe pointer expression.
updateConstraintOperatorUpdateConstraintOperatorThe operator that determines the type of comparison.
valueTValueThe value.
Returns
- IPartialJSON
The new constraint including the specified
pointer.
Type Parameters
TValueThe value type of the value at the pointer.
Remarks
If there is no value found at the specified pointer position, the constraint will be unsatisfied.
If a System.String value is supplied and the operator is
EQ or NE, the string
representation of the topic value at the given pointer will be
compared to the supplied value. If the value at the pointer position
is not a string or number the constraint will be unsatisfied. Other
operators (other than IS) are not permitted with
string values.
If a number value (System.Int32, System.Int64 or System.Double) is supplied the
value will be compared with the number value at the topic location.
This will work with JSON string or number values only. JSON strings
can only be compared if they contain a value that can be parsed as a
number. If a string value at the location cannot be parsed as a
number, the constraint will be unsatisfied. Any of the operators
(other than IS) can be used with such number
comparisons. Decimal numbers can be compared with integral numbers so
1 is equal to 1.0, "1", or "1.0".
If a null value is supplied and the operator is
EQ or NE, the topic value at
the given pointer will be compared to JSON null. Other operators
(other than IS) are not permitted with a
null value.
If a System.Boolean value is supplied and the operator is
EQ, the topic value at the given pointer will be
compared to the boolean value. Other operators are not permitted with
a boolean value.
If the IS operator is specified the supplied
value will be compared to the topic value for strict binary equality.
In this case the value must be of type System.String, System.Int32, System.Int64,
System.Double, IBytes, or null. This is slightly more
efficient than the lenient comparisons described above.
Since 6.10.
The pointer is a JSON Pointer (https://tools.ietf.org/html/rfc6901) syntax reference
locating the value in the JSON object.
The pointer syntax is not being verified for correctness.
Exceptions
- ArgumentException
If the
valuetype is not supported, or the operator is not compatible with thevaluetype.
With<TValue>(string, TValue)
Requires a value at a specific position in the JSON object.
[Obsolete("Rather use the With<TValue>(string, UpdateConstraintOperator, TValue) method with the UpdateConstraintOperator.IS operator", false)]
IPartialJSON With<TValue>(string pointer, TValue value)
Parameters
pointerstringThe pointer expression.
valueTValueThe value.
Returns
- IPartialJSON
The new constraint including the specified
pointer.
Type Parameters
TValueThe value type of the value at the pointer.
Remarks
Caution
Deprecated since 6.10. Rather use the With<TValue>(string, UpdateConstraintOperator, TValue) method with the IS operator.
This is equivalent to calling With<TValue>(string, UpdateConstraintOperator, TValue) with an operator of IS.
The pointer is a JSON Pointer (https://tools.ietf.org/html/rfc6901) syntax reference
locating the value in the JSON object.
The pointer syntax is not being verified for correctness.
Exceptions
- ArgumentException
If the class of the supplied value is not supported.
Without(string)
Requires a specific position in the JSON object to be absent. This does not match positions that have null values.
IPartialJSON Without(string pointer)
Parameters
pointerstringThe pointer expression.
Returns
- IPartialJSON
The new constraint including the specified
pointer.
Remarks
The pointer is a JSON Pointer (https://tools.ietf.org/html/rfc6901) syntax reference
that should have no value in the JSON object.
The pointer syntax is not being verified for correctness.