handle duplicate JSON keys only when possible