7

I'm just learning jsonschema. It's not clear to me what the difference is between items and properties. Can someone please explain?

Relequestual
  • 11,631
  • 6
  • 47
  • 83
jlconlin
  • 14,206
  • 22
  • 72
  • 105

1 Answers1

6

items is for validating arrays, properties is for validating objects.

The value of items must be a JSON Schema object or an array JSON Schema objects (let's ignore if it's an array for now). The array that the items key word is applicable to, passes validation if all items in that array validate against the schema.

The value of properties must be an object. Each value in the object must be a json schema. The schemas in the object are applied to the instance object when the keys match.

Relequestual
  • 11,631
  • 6
  • 47
  • 83
  • There are some updated resources for learning at json-schema.org/learn/ - You may also join the official slack channel if you have any questions which fall outside of those acceptable on SO. – Relequestual Aug 02 '18 at 08:35
  • I've visited json-schema.org/learn and have spent some time there. I must have missed the discussion about `items` and `properties`. You are already being helpful on the slack channel. Thanks! – jlconlin Aug 02 '18 at 12:50