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

bug when ignore_string_case=True #515

Open
jbones001 opened this issue Dec 30, 2024 · 4 comments
Open

bug when ignore_string_case=True #515

jbones001 opened this issue Dec 30, 2024 · 4 comments

Comments

@jbones001
Copy link

When setting ignore_string_case=True, all the keys in the deepDiff results become lowercase. This is an issue if using the key names to display to the user and you want the original case preserved

@watercloset128
Copy link

watercloset128 commented Jan 29, 2025

Same issue probably. When setting ignore_string_case=True, all the keys in the deepDiff results become lowercase. This issue leads to a failed comparison when there are the keys that are case sensitive in json files. Please be realized that it seems only affects the comparison for the string value. For the other keys with other value types, the comparison still works. Please refer to the attached json files and the parameters I set, and output for your reference.

function call: diff = DeepDiff(json1, json2, exclude_paths=exclude_path_list, exclude_regex_paths=exclude_path_reg_list, ignore_string_case=True, verbose_level=2)

exclude_path_list=["root['headers']['uploadedOn']", "root['headers']['path']", "root['headers']['uploadedBy']", "root['headers']['timestamp']", "root['headers']['version']", "root['calibration']['chksum']", "root['runs']['dateInUTC']", "root['runs']['dateOutUTC']", "root['runs']['client']", "root['runs']['WellboreDiameter']", "root['performance_metrics']"]
exclude_path_reg_list=["root\['toolset'\]\[\d+\]\['currentSiteHierarchy'\]", "root\['toolset'\]\[\d+\]\['siteHierarchy'\]", "root\['toolset'\]\[\d+\]\['description'\]", "root\['toolset'\]\[\d+\]\['partnumber'\]", "root\['toolset'\]\[\d+\]\['revisionlevel'\]"]

expected output: {}
actual output: {'values_changed': {"root['headers']['uploadedon']": {...}, "root['headers']['uploadedby']": {...}}}

1738172292455-impulse-results.json

baseline-results.json

@seperman
Copy link
Owner

seperman commented Mar 5, 2025

@jbones001 @watercloset128 What we can do is to cache a dictionary or the lower case key to one of the ways it appears in your data. And then when we report the key, we show you one of those ways. Does that make sense?

Your uploadedOn and UploadedOn and uploadedON will all be reported the same as uploadedOn.

What do you think?

@watercloset128
Copy link

@jbones001 @watercloset128 What we can do is to cache a dictionary or the lower case key to one of the ways it appears in your data. And then when we report the key, we show you one of those ways. Does that make sense?

Your uploadedOn and UploadedOn and uploadedON will all be reported the same as uploadedOn.

What do you think?

@seperman no matter which way you mentioned, I would prefer to keep the key case sensitive exactly as it is while comparing its string value with ignoring the case sensitivity. Because, from a developer or a DeepDiff "user" perspective, it would be preferable in the more intuitive way, which is simply to take the key from the file to be compared and check the values from the key as it is by the user set. So, when you mentioned that uploadedOn and UploadedOn and uploadedON will all be reported the same as uploadedOn, it is quite meaningless to me at least because I won't even think of using the format of UploadedOn and uploadedON.

So, I would prefer the better way I mentioned above if there is a possibility to make it. However, I am not quite sure if it's quite challenging to implement it. The bottom line, from my understanding, the way of using exclude_path_list below will work while the key in uploadedOn and UploadedOn and uploadedON is going to work as well.

Anyway, appreciate your effort on fixing the issues! Even with those being said, I am quite satisfied with DeepDiff that I can compare json files in a clear and intuitive way without taking too much care of complex parameters in the most cases.

exclude_path_list=["root['headers']['uploadedOn']", "root['headers']['path']", "root['headers']['uploadedBy']", "root['headers']['timestamp']", "root['headers']['version']", "root['calibration']['chksum']", "root['runs']['dateInUTC']", "root['runs']['dateOutUTC']", "root['runs']['client']", "root['runs']['WellboreDiameter']", "root['performance_metrics']"]

@jbones001
Copy link
Author

I agree with @watercloset128

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

No branches or pull requests

3 participants