We need to define a format for JSON schemas to describe the fields that a widget can have. A widget can have individual fields, or have repeatable fieldsets (in the way that a carousel widget can have a single title, as well as an array of slides with their own individual fields). My colleague and I disagree over the most intuitive format for such a schema. Please help us choose!
Repeatable fieldsets are denoted by JSON Objects, and string values are known datatypes:
{
"title": "string",
"slides": {
"name": "string",
"body": "text",
"image": "image"
}
}Repeatable fieldsets are denoted by Arrays, and string values are known datatypes:
{
"title": "string",
"slides": [{
"name": "string",
"body": "text",
"image": "image"
}]
}The contentious issue is whether it is counterintuitive to indicate array data by using an object.
Dev A thinks this is simple and intuitive and avoids the arbitrary and unnecessary awkwardness of always having to use a single-element array to indicate that the expected data for that field will be an array, but acknowledges that with Option A, there's no way to group a set of related fields in a named fieldset without it being interpreted as an array, though this is not presently a requirement of the app.
Dev B considers it highly counterintuitive that you would use an object in the schema to represent what will be an array, and points out that in Option B, it's not just a bonus/coincidence but to be expected that the schema object as actually a valid object that conforms to itself, i.e. it is an object whose title is "string", and its value slides is already in array format. To Dev B, this will minimize the context switch that a client developer will need to undergo to switch between defining the schema and defining objects that conform to that schema.
This is a surprisingly heated debate, and maybe it shouldn't be, but please weigh in if you have a moment and let us know if one of us is crazy or if we're both overlooking a third way. Assume for this projects that both schema and conforming object data must be in JSON format.
I know what Option B would look like with multiple
slides. Maybe I'm missing something in the explanation, but how would Option A represent multipleslides?