0

Trying to create a schema of the below JSON.

{
  "peopleNames": [
    {
      "name": "John Doe",
      "Address": "10th Street, Chicago, WI",
      "jobInformation": {
        "employers": [
          "ABC",
          "ChocolateFactory"
        ]
      },
      "employers": {
        "ABC": {
          "employeeID": "1234"
        },
        "ChocolateFactory": {
          "employeeID": "4567"
        }
      }
    },
    {
      "name": "Jamie Soe",
      "Address": "110th Street, Seattle, WA",
      "jobInformation": {
        "employers": [
          "McDonalds",
          "RedRobin"
        ]
      },
      "employers": {
        "McDonalds": {
          "employeeID": "1234"
        },
        "RedRobin": {
          "employeeID": "4567"
        }
      }
    }
  ]
}

The properties of "employers" is dependent on the value of the jobInformation.employers list. The value of employers are not dependent on any enum and can be random. I need to validate that the value of employers has the same properties as the jobInformation.employers.

I dont understand how I can achieve that. Thanks in advance.

constantLeaner
  • 157
  • 1
  • 4
  • 12
  • 2
    If you don’t know the possible employers upfront, I‘m afraid what you’re describing falls under „business logic“ and is therefore out-of-scope for the JSON Schema specification. There might not be a way to achieve this (as of the current Draft 2019-09). – Carsten May 07 '20 at 22:34
  • The duplicate question has the same answer as the above comment. Sorry this is not possible with JSON Schema. – Relequestual May 08 '20 at 11:31

0 Answers0