lua-users の Json Modules (http://lua-users.org/wiki/JsonModules) の pure lua で書かれてるものを読んでみた.
基本的にはそれぞれ独自に array 判定関数を作っていて, 中身のロジックは大体同様で以下のようなものだった.
- テーブル内のすべてのキーをチェックする
- type が number かつ連番であれば, array とみなす
- 空のテーブルは空のリストとする
lua-users の Json Modules (http://lua-users.org/wiki/JsonModules) の pure lua で書かれてるものを読んでみた.
基本的にはそれぞれ独自に array 判定関数を作っていて, 中身のロジックは大体同様で以下のようなものだった.
a = "a" | |
b = "b" | |
c = "c" | |
print(a and b or c) -- b | |
a = nil | |
b = "b" | |
c = "c" | |
print(a and b or c) -- c |
SELECT COUNT(*), SUBSTRING(HOST, 1, POSITION(':' in HOST)-1) AS ip FROM INFORMATION_SCHEMA.PROCESSLIST GROUP BY ip; |
#!/bin/sh | |
change_set_arn=arn:aws:cloudformation:ap-northeast-1:xxxxxxxxxxxxxxxxxxxxx | |
aws cloudformation describe-change-set --change-set-name $change_set_arn | jq '.Changes[].ResourceChange | select(.Scope[] | contains("Tags") | not) | .' |
#!/bin/sh | |
change_set_arn=arn:aws:cloudformation:ap-northeast-1:xxxxxxxxxxxxxxxxxxxxx | |
aws cloudformation describe-change-set --change-set-name $change_set_arn | jq '.Changes[].ResourceChange | select(.Scope[] | contains("Tags") | not) | .' |
aws ec2 describe-instances | jq -r '.Reservations[].Instances[].Tags[] | select(.Key == "Name") | .Value' |
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo "ERROR: Need profile name" | |
exit 1 | |
fi | |
profile_name=$1 | |
stack_name=$(aws cloudformation list-stacks --profile ${profile_name} --region ap-northeast-1 \ | |
| jq -r '.StackSummaries[] | .StackName + "\t" + .StackStatus' \ |