Datasets:
File size: 396 Bytes
44353e7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Copyright The Marin Authors
# SPDX-License-Identifier: Apache-2.0
"""Reject ambiguous duplicate keys while decoding trusted JSON objects."""
def unique_object(pairs: list[tuple[str, object]]) -> dict[str, object]:
result = {}
for key, value in pairs:
if key in result:
raise ValueError(f"duplicate JSON key {key!r}")
result[key] = value
return result
|