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

chore: JSON.GET now works with our own jsonpath #2653

Merged
merged 1 commit into from
Feb 24, 2024
Merged

chore: JSON.GET now works with our own jsonpath #2653

merged 1 commit into from
Feb 24, 2024

Conversation

romange
Copy link
Collaborator

@romange romange commented Feb 23, 2024

No description provided.

@@ -30,6 +30,12 @@ class TestDriver : public Driver {
}
};

inline JsonType ValidJson(string_view str) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

a convenience wrapper

@@ -123,6 +129,19 @@ TEST_F(JsonPathTest, Parser) {
EXPECT_EQ(0, Parse("$.plays[*].game"));
}

TEST_F(JsonPathTest, Root) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the only change is this test. Now for empty Path we return the whole object to satisfy $ query.

@@ -65,6 +65,17 @@ inline void Evaluate(const json::Path& expr, const JsonType& obj, ExprCallback c
});
}

inline JsonType Evaluate(const JsonExpression& expr, const JsonType& obj) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

a special variant of Evaluate that does not accept a callback and instead returns all the hits as a json array.

return expr.evaluate(obj);
}

inline JsonType Evaluate(const json::Path& expr, const JsonType& obj) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same variant for json::Path

@romange romange merged commit 2b30f69 into main Feb 24, 2024
10 checks passed
@romange romange deleted the Pr2 branch February 24, 2024 11:23
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.

None yet

2 participants