R
R
Roman Krylov2015-02-21 23:54:55
JavaScript
Roman Krylov, 2015-02-21 23:54:55

How to describe the JSON Schema so that only the key of another object can be specified in the property value?

In the project admin panel I use Treema , which generates an HTML interface for me to edit my JSON object according to the scheme given to me.
Let's say the object looks like this:

{
  "cities": {
    "moscow": {"name":"Москва"},
    "sochi": {"name":"Сочи"},
    "irkutsk": {"name":"Иркутск"}
  },
  "projects": {
    "a": { "city": "moscow" },
    "b": { "city": "sochi" },
    "с": { "city": "sochi" },
    "d": { "city": "irkutsk" },
    "e": { "city": "newyork" }
  }
}

Question: Is it possible, and if so, how in the schema to describe that the value of the city property in projects descendants can be only one of the keys of the cities child elements ? If this cannot be described in the schema, then how can Treema force it to invalidate projects.e.city in a given code example?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question