Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate keys in JSON objects are lost #695

Open
dkg opened this issue May 23, 2024 · 1 comment
Open

duplicate keys in JSON objects are lost #695

dkg opened this issue May 23, 2024 · 1 comment
Labels

Comments

@dkg
Copy link

dkg commented May 23, 2024

in tshark.py, _duplicate_object_hook is defined and declared to "Make lists out of duplicate keys". However, it doesn't make lists out of duplicate keys:

def _duplicate_object_hook(ordered_pairs):
    """Make lists out of duplicate keys."""
    json_dict = {}
    for key, val in ordered_pairs:
        existing_val = json_dict.get(key)
        if not existing_val:
            json_dict[key] = val
        else:
            # There are duplicates without any data for some reason, if it's that - drop it
            # Otherwise, override
            if val.get("properties") != {}:
                json_dict[key] = val

    return json_dict

This was introduced in 862e4a6 -- which doesn't have enough in the git commit message to explain why it is done this way.

@dkg dkg added the bug label May 23, 2024
@dkg
Copy link
Author

dkg commented May 23, 2024

Note that p.3 of the json standard says:

The JSON syntax does not impose any restrictions on the strings used as names, does not require that name strings be unique, and does not assign any significance to the ordering of name/value pairs. These are all semantic considerations that may be defined by JSON processors or in specifications defining specific uses of JSON for data interchange

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant