-
Notifications
You must be signed in to change notification settings - Fork 3
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
Enhancement: jstrdecode should have a command line option to ignore newlines #21
Comments
I like this thought. If I understand it correctly this would skip past the byte |
With echo -n 'å∫ç∂' 'ƒ©˙' | jstrdecode and: echo 'å∫ç∂
ƒ©˙' | jstrdecode -N would produce the same thing? UPDATE 0See also GH-issuecomment-2405771581 ᐤ. UPDATE 1bRegarding GH-issuecomment-2405775932), see Unicode control points such as U+1424 and U+2218. Perhaps a short scan of a List of Unicode Symbols would find better examples. Other candidates could be U+07CB, U+09F9, U+0A66, U+0C66, U+0F1A, U+20DD, U+25CB, U+25CE, U+25EF, u+26AC, U+2B55, U+2D54, and U+FFEE. |
I wonder. I was just doing it so it would skip the final newline which seems reasonable. But the question is if one uses it this way what does a final newline do? Meaning a trailing newline?
I replied with a question on that. |
I just implemented the way I interpreted it. I can commit. If you wish for more then let me know. I have to check one thing. After this I then must do other things. (Okay did it in decode only: have to look at encode also.) |
Regarding GH-issuecomment-2405774413, see the suggestion for processing internal newlines with The We suggest that with |
Please do commit, and feel free to add it to the "other repo". |
I'll do that and the other part can happen later I guess as I have another question about that way. |
Okay assuming I remove internal I guess if it's the final byte it would be like I am doing now? |
We suggest you delete it from the buffer. The command: jstrdecode 'foo' 'bar' concatenates both "foo" and "bar". So think of: (echo "foo"; echo "bar") | jstrdecode -N as removing both newlines and concatenating the results. Think of each line on stdin as a separate argument where UPDATE 0With BTW: This should also work: jstrdecode -N "hi
hello
there" Just as if we did: echo "hi
hello
there" | jstrdecode -N and just as if we did: jstrdecode hi hello there |
About to do a pull request. If you wish to explain your further idea with |
With
|
Okay I understand now. Not sure I can do this today but the final newline is at least removed now. Perhaps you would like to do this quickly before the freeze over there? That would be appreciated if you have the time. Otherwise I can do it tomorrow I guess (or later today if I have time - but I doubt it). |
We have a tested PR that we will issue to the jparse repo. Then we will fold that PR into this repo after we complete the existing PR processing to be sure we stay in sync. |
If you think your updates resolves this issue then please feel free to close this, or let me know and I'll close it. If not then please let me know what else you think needs to be done. |
Thanks for taking the time doing that! Really appreciate it. |
I see that you added |
Sure. Please make sure to update the man page too. You can then sync to mkiocccentry when you're all done. I should be able to merge it today but if I don't get to it today I'll certainly do it in the morning (when I'm awake enough to look at it). I guess that won't matter for a code freeze over in the mkiocccentry repo. Even so I'll be awake for many more hours just not as many as you. |
PR is own the way soon, after man page edits. |
Sounds good. Thanks! |
Feel free to do the update you were thinking of with |
Double free bug .. need to fix. |
Forgot to set to NULL? Or did I do something when I did the original addition very quickly ? Well anyway no problem. I will be going afk shortly but I'll have my phone with me. |
The |
I hope you're a strong swimmer! |
Fixed. |
Doing the man page change now. |
Great. |
Thanks! |
Done. Just a bit of hand testing now ... |
building the commit ... |
Sounds good. |
creating the PR ... Watching the GitHub test ...
🤓 |
See PR #23 |
We believe this issue has been completed. |
Maybe I should have done the other one as well but the joke of course is that you have this person praying and yet a dragon is consuming them in fire! |
Is there an existing issue for this?
Describe the enhancement
When
jstedecode(1)
processes data from stdin, it should have a command line option to ignore newlines.Consider:
This will generate the following unhelpful error:
Whereas this works:
and produces:
The same problem happens when you use the
-
(dash character) arg:IMPORTANT NOTE: Objecting to a "naked" newline in a JSON string IS CORRECT BEHAVIOR as the so-called JSON spec does NOT allow for "naked" newlines in JSON strings.
Relevant images, screenshots or other files
echo Hello, World! | jstrdecode
:-)Relevant links
🔗⛓️
Anything else?
This is NOT a priority. The bin tools on that "other" repo supply a
-T
to trim outgoing newlines before feeding them intojstrdecode -
. So there is no need for an emergency fix. We held off on making this change until after the code freeze."Technically and pedantically speaking" (as the expression goes), the current behavior of
jstrdecode(1)
is correct. The tool does "decode JSON encoded strings" and in the so-called JSON spec, newlines characters are NOT allowed. The JSON parserjparse(1)
and its friendly library should NOT be relaxed to allow for naked newline characters in JSON documents.Perhaps
jstrdecode(1)
shouldjstrdecode(1)
have an option to ignore any final newline?We observe that its companion
jstrencode(1)
tool has-n
:As does
jstrdecode(1)
:Perhaps a new option such as
-N
should telljstrdecode
to ignore a final newline, such that this would work:Note that internal newlines would still cause this to fail:
This is NOT a priory enhancement request.
The text was updated successfully, but these errors were encountered: