How to convert a json string into an individual character array in bash?

mjd

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.

oguz ismail

In jq, splitting a string by empty string results in a character array just as you need.

jq '.[].password |= split("")' file

Online demo at jqplay.org

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Convert String to JSON in bash

분류에서Dev

How do I convert a TTF into individual PNG character images?

분류에서Dev

how to convert a character array to decibel

분류에서Dev

Convert an array of character to string from index i to j in c++

분류에서Dev

Trying to Convert String to Character Pointer?

분류에서Dev

How to convert a string to lower case using bash 3.1 available in gitExtension

분류에서Dev

In bash, how can I convert a Unicode Codepoint [0-9A-F] into a printable character?

분류에서Dev

Average of occurrences of a character in a string array

분류에서Dev

Convert array to string Javascript

분류에서Dev

Swift Convert Hex String or Character to Integer

분류에서Dev

Bash script: array elements containing space character

분류에서Dev

How to convert a UUID that saved in an array of bytes into a string (c++)

분류에서Dev

How do I convert a JSON String into a GSON Object?

분류에서Dev

How can I convert that json string to my class

분류에서Dev

PHP array into individual php string, from SQL data

분류에서Dev

Convert to string from an array of characters

분류에서Dev

Check that string contains a character from array

분류에서Dev

Pass a string or array as arguments in bash

분류에서Dev

How to convert decimal value to character in c language

분류에서Dev

How to convert unicode to its original character in Python

분류에서Dev

how to search a string for a character and no where it is in the string then change it

분류에서Dev

how to search a string for a character and no where it is in the string then change it

분류에서Dev

Convert byte array string back to a string

분류에서Dev

aws athena convert array <array <string >> to table

분류에서Dev

copy array with array name inside string in bash

분류에서Dev

How to convert this JSON to a datatable?

분류에서Dev

Convert JSON bidimensional array to an AS3 array

분류에서Dev

How to assign JSON array to a string using the SimpleJSON library in C++

분류에서Dev

How to convert datatable to json string output using json.net WCF Rest Service

Related 관련 기사

  1. 1

    Convert String to JSON in bash

  2. 2

    How do I convert a TTF into individual PNG character images?

  3. 3

    how to convert a character array to decibel

  4. 4

    Convert an array of character to string from index i to j in c++

  5. 5

    Trying to Convert String to Character Pointer?

  6. 6

    How to convert a string to lower case using bash 3.1 available in gitExtension

  7. 7

    In bash, how can I convert a Unicode Codepoint [0-9A-F] into a printable character?

  8. 8

    Average of occurrences of a character in a string array

  9. 9

    Convert array to string Javascript

  10. 10

    Swift Convert Hex String or Character to Integer

  11. 11

    Bash script: array elements containing space character

  12. 12

    How to convert a UUID that saved in an array of bytes into a string (c++)

  13. 13

    How do I convert a JSON String into a GSON Object?

  14. 14

    How can I convert that json string to my class

  15. 15

    PHP array into individual php string, from SQL data

  16. 16

    Convert to string from an array of characters

  17. 17

    Check that string contains a character from array

  18. 18

    Pass a string or array as arguments in bash

  19. 19

    How to convert decimal value to character in c language

  20. 20

    How to convert unicode to its original character in Python

  21. 21

    how to search a string for a character and no where it is in the string then change it

  22. 22

    how to search a string for a character and no where it is in the string then change it

  23. 23

    Convert byte array string back to a string

  24. 24

    aws athena convert array <array <string >> to table

  25. 25

    copy array with array name inside string in bash

  26. 26

    How to convert this JSON to a datatable?

  27. 27

    Convert JSON bidimensional array to an AS3 array

  28. 28

    How to assign JSON array to a string using the SimpleJSON library in C++

  29. 29

    How to convert datatable to json string output using json.net WCF Rest Service

뜨겁다태그

보관