Skip to content

PYTHON-5121 - Use canonical Extended JSON for BSON binary vector spec… #2215

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

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

NoahStapp
Copy link
Contributor

… tests

@NoahStapp NoahStapp requested a review from caseyclements March 24, 2025 15:05
@@ -27,6 +27,15 @@
_TEST_PATH = Path(__file__).parent / "bson_binary_vector"


def convert_extended_json(vector) -> float:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we load the entire JSON file using json_util.loads() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new json_util.load() method for this exact purpose.

@NoahStapp NoahStapp requested review from ShaneHarvey and removed request for caseyclements March 24, 2025 18:16
@@ -507,6 +507,29 @@ def loads(s: Union[str, bytes, bytearray], *args: Any, **kwargs: Any) -> Any:
return json.loads(s, *args, **kwargs)


def load(fp: Any, *args: Any, **kwargs: Any) -> Any:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's open a new ticket for this. Adding this increases the scope of this ticket too much and opens other questions like "do we also need json_util.dump?"

I also question if this is valuable enough to add since it's pretty simple to use json_util.loads:

json_util.loads(fp.read())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point--I don't think we need json_util.load() when we can use json_util.loads(fp.read()).

@NoahStapp NoahStapp requested a review from ShaneHarvey March 24, 2025 19:41
@NoahStapp NoahStapp merged commit 296046c into mongodb:master Mar 24, 2025
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants