Fix #1418 (problem with JSON unflatten when using common prefixes)