I have a JSON file with content this:-
{
"content": "{\"accountNumber\":\"12345\",\"transactionId\":\"568\",\"socialSecurityNumber\":\"123456796\",\"identificationNumber\":1,\"securityCode\":\"1234\",\"dateOfBirth\":\"1000-01-01\",\"firstName\":\"qwerty\",\"lastName\":\"xyz\",\"balance\":123}",
"contentType": "application/json",
"createdAt": "2020-11-11T12:55:41.350+0000",
"cryptoKeyId": null
}
I just want to update the value of firstName . End result I want is
{
"content": "{\"accountNumber\":\"12345\",\"transactionId\":\"568\",\"socialSecurityNumber\":\"123456796\",\"identificationNumber\":1,\"securityCode\":\"1234\",\"dateOfBirth\":\"1000-01-01\",\"firstName\":\"abcdef\",\"lastName\":\"xyz\",\"balance\":123}",
"contentType": "application/json",
"createdAt": "2020-11-11T12:55:41.350+0000",
"cryptoKeyId": null
}
I tried this
( .content | fromjson.firstName = "abcdef" )
but no success. Can you help me here? Thanks
由于您想更新该值,您可以使用|=
,并且不要忘记对tojson
的调用:
.content |= (fromjson | (.firstName = "abcdef") | tojson)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.