Add support for mixed-level nested keys with dot/blank handling

- Handle @parent:child and @parent🧒grandchild coexistence
- Use '.' key for parent values when nested children exist
- Add comprehensive test cases for double-nested scenarios
- Support both '.' and '' as special keys for parent values
This commit is contained in:
Dan Jones 2026-02-12 10:41:35 -06:00
commit 6095c2497e
3 changed files with 53 additions and 5 deletions

View file

@ -50,12 +50,16 @@ func marshalMap(pre string, mp map[string]any, buff *bytes.Buffer) error {
buff.WriteRune('\n')
}
idx++
newKey := pre + ":" + k
if k == "." || k == "" {
newKey = pre
}
if subM, ok := v.(map[string]any); ok {
if err := marshalMap(pre+":"+k, subM, buff); err != nil {
if err := marshalMap(newKey, subM, buff); err != nil {
return err
}
} else {
mSub := Meta{pre + ":" + k, v}
mSub := Meta{newKey, v}
if err := mSub.marshalToBuff(buff); err != nil {
return err
}