• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to use the linux command line json parser (jq) to extract a specific value?

Resolved: How to use the linux command line json parser (jq) to extract a specific value?

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I’m running this command line json parser (jq) in Debian GNU/Linux 11 (bullseye) to decode the json data:

jq -R ‘split(".") | .[0],.[1] | @base64d | fromjson’ <<< eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjE2NTUzODQ4MzJ9.QVevY3qVLWHxfkNX1S4bas6PKSN75Nf96V7WmkcgbrE


Instead of returning ALL key/value pairs, is there a way to modify that command to extract only the expiration date 1655384832 value?

Answer:

You don’t need the first object, you can ignore it (remove [0]). Then just specify which key you want:

jq -R ‘split(“.”) | .[1] | @base64d | fromjson | .exp’ <<< ... [/code]

If you have better answer, please add a comment about this, thank you!

jq json linux
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: VBA – Applying border around the areas with value/text

01/04/2023

Resolved: How can I implement a function depending on picked up items?

01/04/2023

Resolved: Azuer Service Bus SDK not receiving the specified messages

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.