newsdev/archieml-js

Nested array string values don't overwrite nested key/value pairs created by scoped arrays

minikomi opened this issue · 3 comments

Test case:

[a.b]
d:e
[]

[a.b]
* c
[]

This is an open question for users: whether arrays should be "sticky" if they're opened multiple times. At the moment, both simple and complex arrays can be reopened:

[complex]
key: value
[]

[complex]
key: value
[]

[simple]
* value
[]

[simple]
* value
[]
{
  "complex": [{"key": "value"}, {"key": "value"}],
  "simple": ["value", "value"]
}

Since an arrays type is decided by whether a key: value or a * value is found first, I think that if you reopen an array, it makes sense in a way to continue to parse only either complex or simple values. (Inside a complex array, * value isn't treated as an array element, and vice versa.)

@minikomi, @archietse - which do you think would be most intuitive for users?

Yep, I didn't realize the key / simple text sticky rule while I was playing about with this. I think once you know the rule, the current behavior makes sense.

We've been discussing this behavior at NYT, and think you're original assumption that later array definitions should overwrite prior definitions is more intuitive. The most recent proposal for the spec reflects this, and archieml-js v0.2.0 has been updated to function this way.