Again fast and a useful blog post all about Emacs and JSON. Let’s assume you have a one-line JSON object. It’s really annoying to read or fix.
|
{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "InfraRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version" : "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::Infra-account-ID:user/Admin" }, "Action": [ "sts:AssumeRole" ] } ] }, "Path": "/" } }, "InfraAccessPolicy" : { "DependsOn" : "InfraRole", "Type" : "AWS::IAM::ManagedPolicy", "Properties" : { "Description" : "Policy for resources managed by Infra", "Path" : "/", "PolicyDocument" : { "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": "*", "Resource": "*" }], "Roles": [ { "Ref": "InfraRole" }] } } } } } |
If you are an Emacs user. M-x json-pretty-print-buffer-ordered Tadaaaaa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "InfraAccessPolicy": { "DependsOn": "InfraRole", "Properties": { "Description": "Policy for resources managed by Infra", "Path": "/", "PolicyDocument": { "Roles": [ { "Ref": "InfraRole" } ], "Statement": [ { "Action": "*", "Effect": "Allow", "Resource": "*" } ], "Version": "2012-10-17" } }, "Type": "AWS::IAM::ManagedPolicy" }, "InfraRole": { "Properties": { "AssumeRolePolicyDocument": { "Statement": [ { "Action": [ "sts:AssumeRole" ], "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::Infra-account-ID:user/Admin" } } ], "Version": "2012-10-17" }, "Path": "/" }, "Type": "AWS::IAM::Role" } } } |
Related topics http://irreal.org/blog/?p=354 http://richardlog.com/post/12743073497/pretty-printing-json-and-xml-on-mac-osx