w3c / mnx

Music Notation CG next-generation music markup proposal.
179 stars 18 forks source link

JSON: Encoding global measures as empty objects #296

Closed adrianholovaty closed 1 year ago

adrianholovaty commented 1 year ago

The "global" object of an MNX document contains a "measures" array, with global information on each measure. At the moment, each measure in the document must be represented by an object — which can result in an array containing lots of empty objects.

For example, see the Multimeasure rests example document:

"global": {
   "measures": [
      {
         "barline": {
            "type": "regular"
         },
         "time": {
            "signature": "4/4"
         }
      },
      {},
      {},
      {},
      {},
      {},
      {}
   ]
}

This is a bit inelegant, and I could see it confusing newcomers to MNX. Is there a better solution?

I should note that the XML version of MNX had this same ugliness, with a bunch of empty elements in the <global> section.

Personally I think it's OK, with the philosophy being that MNX will be created and consumed by programs, but I'm bringing it up in case anybody has an amazing better idea.

adrianholovaty commented 1 year ago

Issue #294 is related — it also concerns empty objects.

mscuthbert commented 1 year ago

It looks fine to me (not from aesthetics but from functionality). Here the default Falsey nature of {} in Python becomes an advantages, since I'd be likely to parse the global object with something like:

globals = {}
for i, obj in enumerate(global):
    if not obj:  # falsy - no attributes.
         continue
    measure_global = MeasureGlobal(obj)
    globals[i] = measure_global
mscuthbert commented 1 year ago

We had a great conversation with some alternates and nothing came better than this way.

adrianholovaty commented 1 year ago

We've just discussed this in our co-chairs meeting and haven't been able to find any better options, so let's mark this as Good Enough.