I have below format of json file
{
"username":"achu",
"password":"test1234"
}
I just want to add timestamp into the above payload and send it as request for some service.
AS per I know the below command will help us to get current stamp on linux:
date +"%r"
but not sure how can I append this into the above payload as like below:
Expected:
{
"username":"achu",
"password":"test1234",
"date":"1:20:30 AM PST"
}
jq --version
1.5v
Is it possible to get it like this?
With GNU awk and gawk-json extension:
Output in my tz:
One of many possibilities:
p.s. Rather than continually asking whether something is possible using jq, you might find it a better investment of your time to become more familiar with jq. A good reference is the official manual: https://stedolan.github.io/jq/manual/
jq has builtin functions for playing with dates, like
will do what you're after in this case