Repository navigation
to json -r not removing whitespaces fix - #11948
Conversation
CHG: changed all affected tests accordingly
| let mut inside_quotes = false; | ||
| let mut last_char = 'p'; // 'p' is just a placeholder, can be anything except for '\\' | ||
| let output = string | ||
| .chars() |
There was a problem hiding this comment.
I'm wondering if chars() could be an issue with some wide unicode characters. Would graphemes() be better here?
There was a problem hiding this comment.
In my understanding it shouldn't be a problem, since the only character that is modified is the whitespace which is checked for with the .is_whitespace() function that also considers unicode characters.
There was a problem hiding this comment.
If you think graphemes() is better, I am happy to change it, but right now I have no time left.
There was a problem hiding this comment.
The only whitespace that should be removed is outside of quotes/strings, which means that it is whitespace added by the encoder. This should only be ever be spaces, tabs, etc. which is covered by char::is_whitespace.
So, I think graphemes is unnecessary.
There was a problem hiding this comment.
In fact, could you change it to is_ascii_whitespace instead? The encoder only emits whitespace characters covered by this. Thanks!
|
On another note, there is a subtle bug regarding escape sequence handling. E.g., {a: '\', b: 'some text'} | to json -rgives |
|
Also, we recently added |
|
Reupping this point:
While great that you figured out a way to strip more of the whitespace back out, this all feels like a needless hack if we could have a code path that never emits the whitespace in the first place. The question would be if |
|
|
Hi, could you tell me what I should do so this PR can be merged? Should I just use the |
Sorry for the confusion @dannou812 , yeah I think the |
|
What's the status on this PR? |
|
I'm sorry I didn't have much time the last two weeks. I will get to it in the next 3 days. Thanks for the patience. |
CHG: removed whitespaces in calender tests
|
I wrapped the call to |
|
We just need to remark on the breaking change |
sholderbach
left a comment
There was a problem hiding this comment.
Thanks for your work and patience on this!
fixes #11900
Description
Replaced the iteration through each json-line applying
str::trimwith an iteration through each character. The iteration now checks whether a character is a whitespace (ignores whitespaces in double quotes) and filters accordingly.If you have any performance concerns please let me know, because I could not think of any.
User-Facing Changes
The problem described in the issue now no longer persists.
Tests + Formatting
I corrected all Tests that were affected by this change.