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

   Á¶È¸ 1924   Ãßõ 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 283/5678
2015-12   1477493   ¹é¸Þ°¡
2014-05   4940620   Á¤ÀºÁØ1
2023-05   2506   »õ¿ËÁö¸¶¾Æ
2023-05   2676   ¹«½î»Ôó·³
2023-05   2815   ±è½ÂÇö1
2023-05   2226   ¹Ì´ã
2023-05   1786   ÀÌÁöÆ÷Åä
2023-05   1776   victor1
2023-05   2411   mybluenote
2023-05   1913   VSPress
2023-05   1164   ¼­¿ï°­ºÏ¹Ì¡¦
2023-05   1752   ¸ÞÅ»Æ÷½º
2023-05   1436   ²Ùºñ
2023-05   3106   ¹«½î»Ôó·³
2023-05   1552   À嵿°Ç2014
2023-05   1896   µµÀå¹ä
2023-05   1877   SDG6038
2023-05   2866   Dqvid
2023-05   2318   ºí·î
2023-05   1930   ¾îµå¹ÎÇ÷¹ÀÌ
2023-05   1280   ¹¹µçÆȾƿä
2023-05   1504   °Ü¿ï³ª¹«