better handling of array items, booleans values, and top-level groups

* use the right (numeric) key when adding items to arrays
* don't allow array keys to be edited
* detect input type for numbers and booleans (don't just default to
string)
* tweak expand() to work at the top level too