I have a json string that I need to convert into an array for passing a password in. Current issue is I need to do this for many users
Current json looks like this which was generated from
[
{
"password": "Password1",
"loginId": "USER1"
}
]
I need to change it to this
[
{
"password":[
"P",
"a",
"s",
"s",
"w",
"o",
"r",
"d",
"1"
],
"loginId":"USER1"
}
]
I'd prefer to do this in bash but if anyone has other options I'm open to anything.
In jq, splitting a string by empty string results in a character array just as you need.
jq '.[].password |= split("")' file
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다