Better JSON parsing #311

Closed
opened 2025-12-29 01:22:18 +01:00 by adam · 7 comments
Owner

Originally created by @lukas2511 on GitHub (Mar 18, 2018).

Originally assigned to: @lukas2511 on GitHub.

Currently dehydrated has very rudimentary JSON parsing which often results in issues with similarly-named values (like the recent #515 where dehydrated used the url string from a sub-dictionary instead of the root).

All JSON parsing should be replaced by something that actually "understands" the JSON structure instead of greping for values inside of it.

I had a look at JSON.sh which looks promising and I actually started stripping it down to only the required functionality and making it compatible with all the bash/zsh options set in dehydrated.

I also looked at some other "libraries" which used awk or sed for the parsing, but those seemed to be problematic on BSD and older GNU/Lunix systems.

So for now I'm planning on integrating JSON.sh, but if anybody knows about similar projects feel free to comment.

Originally created by @lukas2511 on GitHub (Mar 18, 2018). Originally assigned to: @lukas2511 on GitHub. Currently dehydrated has very rudimentary JSON parsing which often results in issues with similarly-named values (like the recent #515 where dehydrated used the `url` string from a sub-dictionary instead of the root). All JSON parsing should be replaced by something that actually "understands" the JSON structure instead of greping for values inside of it. I had a look at JSON.sh which looks promising and I actually started stripping it down to only the required functionality and making it compatible with all the bash/zsh options set in dehydrated. I also looked at some other "libraries" which used awk or sed for the parsing, but those seemed to be problematic on BSD and older GNU/Lunix systems. So for now I'm planning on integrating JSON.sh, but if anybody knows about similar projects feel free to comment.
adam added the bug label 2025-12-29 01:22:18 +01:00
adam closed this issue 2025-12-29 01:22:18 +01:00
Author
Owner

@bzed commented on GitHub (Apr 24, 2018):

https://github.com/stedolan/jq is available in most distributions these days. Not on older systems, though.

@bzed commented on GitHub (Apr 24, 2018): https://github.com/stedolan/jq is available in most distributions these days. Not on older systems, though.
Author
Owner

@vidensky commented on GitHub (Feb 5, 2020):

Step-ca authority does not work due to bad parsing of JSON.
see # 689

@vidensky commented on GitHub (Feb 5, 2020): Step-ca authority does not work due to bad parsing of JSON. see # 689
Author
Owner

@lukas2511 commented on GitHub (Feb 6, 2020):

I'm going to prioritize work on this. Will be the next thing after getting the code-testing system running (which for me is a hard requirement before I'm going to change anything around JSON parsing).

@lukas2511 commented on GitHub (Feb 6, 2020): I'm going to prioritize work on this. Will be the next thing after getting the code-testing system running (which for me is a hard requirement before I'm going to change anything around JSON parsing).
Author
Owner

@vidensky commented on GitHub (Feb 6, 2020):

This is good news.

Yesterday we looked at JSON.sh, https://github.com/step-/JSON.awk and https://github.com/stedolan/jq.

JQ is in my opinion the best choice. Even at the cost of dependence on another utility. JQ has been in the Debian repository since version 8. So 5 years ago. on other OS versions, we didn't look.

@vidensky commented on GitHub (Feb 6, 2020): This is good news. Yesterday we looked at JSON.sh, https://github.com/step-/JSON.awk and https://github.com/stedolan/jq. JQ is in my opinion the best choice. Even at the cost of dependence on another utility. JQ has been in the Debian repository since version 8. So 5 years ago. on other OS versions, we didn't look.
Author
Owner

@lukas2511 commented on GitHub (Feb 6, 2020):

@vidensky Yea, i'd really like to simply use jq, but since dehydrated is running on a lot of older systems where jq is not available that would be not-so-great for a big part of the userbase. I have a prototype of a JSON.sh integration... somewhere... (it's been a while ago...), I think that would be the best route to take.

@lukas2511 commented on GitHub (Feb 6, 2020): @vidensky Yea, i'd really like to simply use jq, but since dehydrated is running on a lot of older systems where jq is not available that would be not-so-great for a big part of the userbase. I have a prototype of a JSON.sh integration... somewhere... (it's been a while ago...), I think that would be the best route to take.
Author
Owner

@lukas2511 commented on GitHub (Jul 5, 2020):

There now is an experimental branch https://github.com/dehydrated-io/dehydrated/tree/jsonsh including JSON.sh as JSON parser.

@lukas2511 commented on GitHub (Jul 5, 2020): There now is an experimental branch https://github.com/dehydrated-io/dehydrated/tree/jsonsh including JSON.sh as JSON parser.
Author
Owner

@lukas2511 commented on GitHub (Sep 30, 2020):

Closing this issue as JSON.sh is now integrated into the main branch. Please open separate issues if you want to report a related problem.

@lukas2511 commented on GitHub (Sep 30, 2020): Closing this issue as JSON.sh is now integrated into the main branch. Please open separate issues if you want to report a related problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/dehydrated#311