Fix #1418 (problem with JSON unflatten when using common prefixes) and add JSON unit test