How to define heterogeneous array items type

103 views
Skip to first unread message

Simone Tripodi

unread,
Oct 12, 2018, 4:17:59 AM10/12/18
to JSON Schema
Hi all,

In Apache Sling we have a Feature model, defined using the JSON format, which mixes usage of "string" and "object" array items type, i.e.

  "bundles":[

    "org.osgi:osgi.core:7.0.0",

    {

      "id":"org.osgi:org.osgi.framework:1.9.0",

      "start-level":"20"

    }

  ]


I am now trying to define a JSON schema for modelling the feature model, but got in trouble how to describe such structure in the schema.

Do you have any suggestion, please?
Any hint will be more than appreciated, many thanks in advance!
~Simo

Felix Meschberger

unread,
Oct 12, 2018, 11:41:35 AM10/12/18
to json-...@googlegroups.com

Hi Simone

 

I think you can use the "anyOf" construct for this:

 

"anyOf": [

  { "type": "string" },

  { "type": "object", "properties": { ... } }

]

 

Regards

Felix

 

Am 12.10.18, 01:18 schrieb "json-...@googlegroups.com im Auftrag von Simone Tripodi" <json-...@googlegroups.com im Auftrag von simone....@gmail.com>:

--
You received this message because you are subscribed to the Google Groups "JSON Schema" group.
To unsubscribe from this group and stop receiving emails from it, send an email to json-schema...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages