Interface IPartialJSON
A constraint requiring the current value of a JSON topic to match the partially described value.
Namespace: PushTechnology.ClientInterface.Client.Features
Assembly: Diffusion.Client.dll
Syntax
public interface IPartialJSON : IUpdateConstraint
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, TValue)
Requires a value at a specific position in the JSON object.
Declaration
IPartialJSON With<TValue>(string pointer, TValue value)
Parameters
Type | Name | Description |
---|---|---|
String | pointer | The pointer expression. |
TValue | value | The value. |
Returns
Type | Description |
---|---|
IPartialJSON | The new constraint including the specified |
Type Parameters
Name | Description |
---|---|
TValue | The 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.
With<TValue>(String, UpdateConstraintOperator, TValue)
Compares a location within the JSON topic value to a specified value.
Declaration
IPartialJSON With<TValue>(string pointer, UpdateConstraintOperator updateConstraintOperator, TValue value)
Parameters
Type | Name | Description |
---|---|---|
String | pointer | The pointer expression. |
UpdateConstraintOperator | updateConstraintOperator | The operator that determines the type of comparison. |
TValue | value | The value. |
Returns
Type | Description |
---|---|
IPartialJSON | The new constraint including the specified |
Type Parameters
Name | Description |
---|---|
TValue | The 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.
Without(String)
Requires a specific position in the JSON object to be absent. This does not match positions that have null values.
Declaration
IPartialJSON Without(string pointer)
Parameters
Type | Name | Description |
---|---|---|
String | pointer | The pointer expression. |
Returns
Type | Description |
---|---|
IPartialJSON | The new constraint including the specified |
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.