How to check if objects in an array are unique by a certain property

Suppose I have this circuit:

"array": {
  "type": "array",
  "items": {
    "type": "object",
    "properties": {"id": {"type": "integer"}, "value": {"type": "number"}}
  },
  "uniqueItems": true
}

      

But I need to make sure that there are no duplicate ID objects in this array. I don't need two objects with the same ID. Is it possible to define a constraint on the uniqueness of an object only by the "id" property?

+3


source to share





All Articles