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

fix: hierarchical json flattening restriction #1058

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nikhilsinhaparseable
Copy link
Contributor

get the level of hierarchy from the json
perform generic flattening only if level of nesting is <=4

get the level of hierarchy from the json
perform generic flattening only if level of nesting is <=4
@coveralls
Copy link

coveralls commented Dec 30, 2024

Pull Request Test Coverage Report for Build 12543071987

Details

  • 93 of 99 (93.94%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 12.168%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/cli.rs 0 3 0.0%
src/kafka.rs 0 3 0.0%
Totals Coverage Status
Change from base Build 12511730436: 0.3%
Covered Lines: 2219
Relevant Lines: 18237

💛 - Coveralls

/// 5. `{"a":{"b":{"c":{"d":{"e":["a","b"]}}}}}` ~> returns error - heavily nested, cannot flatten this JSON
pub fn flatten_json(value: &Value) -> Result<Vec<Value>, anyhow::Error> {
if has_more_than_four_levels(value, 1) {
return Err(anyhow!("heavily nested, cannot flatten this JSON"));
Copy link
Contributor

@de-sh de-sh Dec 30, 2024

Choose a reason for hiding this comment

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

Why error out? Why not just not flatten upto a certain extent and keep the type as is afterwards?

Copy link
Contributor

Choose a reason for hiding this comment

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

i.e. {"a": [{"b":{"c":{"d":["e","f"]}}}, "c": {}]} ~> [{"a":{"b":{"c":{"d":["e","f"]}}}}, {"a":{"c": {}}}]

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

Successfully merging this pull request may close these issues.

4 participants