[ JSON ] jq »ç¿ë¹ý ¹®ÀÇ

   Á¶È¸ 1929   Ãßõ 0    

아래의 문서를 json형식으로 판단이 되어 지는데, 가독성이 좋게 출력할 수 있는 방법이 있을런지요 ?
아시는 분의 조언 부탁 드립니다.


❯ cat a1
{
    "DecodedMessage":
"{\"allowed\":false,\"explicitDeny\":false,\"matchedStatements\":{\"items\":[]},\"failures\":{\"items\":[]},\"context\":{\"principal\":{\"id\":\"ABCDEFGHIJKLMNO\",\"name\":\"AWS-User\", \"arn\":\"arn:aws:iam::accountID:user/test-user\"},\"action\":\"iam:PassRole\", \"resource\":\"arn:aws:iam::accountID:role/EC2_instance_Profile_role\",\"conditions\":{\"items\":[{\"key\":\"aws:Region\",\"values\":{\"items\":[{\"value\":\"us-east-2\"}]}}, {\"key\":\"aws:Service\",\"values\":{\"items\":[{\"value\":\"ec2\"}]}},{\"key\":\"aws:Resource\",\"values\":{\"items\":[{\"value\":\"role/EC2_instance_Profile_role\"}]}}, {\"key\":\"iam:RoleName\",\"values\":{\"items\":[{\"value\":\"EC2_instance_Profile_role\"}]}},{\"key\":\"aws:Account\",\"values\":{\"items\":[{\"value\":\"accountID\"}]}}, {\"key\":\"aws:Type\",\"values\":{\"items\":[{\"value\":\"role\"}]}},{\"key\":\"aws:ARN\",\"values\":{\"items\":[{\"value\":\"arn:aws:iam::accountID:role/EC2_instance_Profile_role\"}]}}]}}}"
}


❯ \cat a1 | jq
{
  "DecodedMessage": "{\"allowed\":false,\"explicitDeny\":false,\"matchedStatements\":{\"items\":[]},\"failures\":{\"items\":[]},\"context\":{\"principal\":{\"id\":\"ABCDEFGHIJKLMNO\",\"name\":\"AWS-User\", \"arn\":\"arn:aws:iam::accountID:user/test-user\"},\"action\":\"iam:PassRole\", \"resource\":\"arn:aws:iam::accountID:role/EC2_instance_Profile_role\",\"conditions\":{\"items\":[{\"key\":\"aws:Region\",\"values\":{\"items\":[{\"value\":\"us-east-2\"}]}}, {\"key\":\"aws:Service\",\"values\":{\"items\":[{\"value\":\"ec2\"}]}},{\"key\":\"aws:Resource\",\"values\":{\"items\":[{\"value\":\"role/EC2_instance_Profile_role\"}]}}, {\"key\":\"iam:RoleName\",\"values\":{\"items\":[{\"value\":\"EC2_instance_Profile_role\"}]}},{\"key\":\"aws:Account\",\"values\":{\"items\":[{\"value\":\"accountID\"}]}}, {\"key\":\"aws:Type\",\"values\":{\"items\":[{\"value\":\"role\"}]}},{\"key\":\"aws:ARN\",\"values\":{\"items\":[{\"value\":\"arn:aws:iam::accountID:role/EC2_instance_Profile_role\"}]}}]}}}"
}


감사합니다.

ªÀº±Û Àϼö·Ï ½ÅÁßÇÏ°Ô.
°­¹ÎÁØ1 2023-03
JSON¾È¿¡ JSONÀÌ ÀÖ´Â ÇüŶó¼­, DecodedMessage ¾È¿¡ ÀÖ´Â °ªÀ» jq·Î »©¼Å¾ß ÇÒ µí ½Í½À´Ï´Ù.
     
°­¹ÎÁØ1 2023-03
cat test.txt | jq '[.DecodedMessage | fromjson | .[]]'

ÀÌ·±½ÄÀ¸·Î ¾²½Ã¸é µÉ °Í °°½À´Ï´Ù.
          
¿Í¿ì.. Ä£ÀýÇÑ ´äº¯ °¨»çÇÕ´Ï´Ù.
jq '[.DecodedMessage | fromjson]' test.txt
ÀÌ·¸°Ô ÇÏ´Ï ´©¶ôµÇ´Â°Ô ¾øÀÌ ´Ù ³ª¿À´Â°Í °°³×¿ä.

ÀÌ·¸°Ô ±îÁö¸¸ Çϼŵµ Á¦°¡ ½áµå¸° À§ Ä¿¸ÇµåÇÏ°í °á°ú´Â µ¿ÀÏÇÕ´Ï´Ù.
cat test.txt | jq '[.DecodedMessage | fromjson ]'


QnA
Á¦¸ñPage 476/5679
2014-05   4942167   Á¤ÀºÁØ1
2015-12   1478980   ¹é¸Þ°¡
2021-08   2249   ö¾ø´Ùö¾ø¾î
2017-11   4919   ÆíÇѼ¼»ó
2020-04   2315   ÀÌÁöÆ÷Åä
2009-07   6687   ±¼´Ù¸®±³
2012-09   11207   HEUo±è¿ë¹Î
2015-11   13186   ȸ¿øK
2021-08   2321   ¹ÌÄ£°¨ÀÚ
2003-07   9464   À±Á¾¹Î
2023-03   1890   inquisitive
2006-03   5763   ÇÑ¿øÁØ
2023-03   1930   Àü¼³¼ÓÀǹ̡¦
2003-07   8788   ¾ÈÀç¿ë
2009-08   5798   ¿ÀÀçÈ£
2012-10   7478   ¹Ú¿ì¿­
2023-04   1860   ´Ù¶ó¹Ì
2012-10   5003   ¸Ó¶óÄ«´Âµ¥
2016-10   8666   ¹«¾Æ
2023-04   2254   Á¾ÀÌ°ÅÀÎ
2015-11   5674   ÀÌÀç¿ëÀÔ´Ï´Ù
2006-03   5555   ±è»óÇö