在Swift中,是否可以将表示仅包含字符串的JSON对象的String
解析为Array
个元组[(String, String)]
(不是Dictionary<String, String>
)?< / p>
我正在编程我的iPhone应用程序,以便将我的服务器的预先签名的回复转发到Amazon S3,这要求客户保留字段的顺序。
这是一个示例JSON字符串,为演示添加了空格:
{
"policy": "eyAiZXhwaXJhdGlvbiI6ICIyMDEzLTA4LTA3VDEyOjAwOjAwLjAwMFoiLA0KICAiY29uZGl0aW9ucyI6IFsNCiAgICB7ImJ1Y2tldCI6ICJleGFtcGxlYnVja2V0In0sDQogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgInVzZXIvdXNlcjEvIl0sDQogICAgeyJhY2wiOiAicHVibGljLXJlYWQifSwNCiAgICB7InN1Y2Nlc3NfYWN0aW9uX3JlZGlyZWN0IjogImh0dHA6Ly9leGFtcGxlYnVja2V0LnMzLmFtYXpvbmF3cy5jb20vc3VjY2Vzc2Z1bF91cGxvYWQuaHRtbCJ9LA0KICAgIFsic3RhcnRzLXdpdGgiLCAiJENvbnRlbnQtVHlwZSIsICJpbWFnZS8iXSwNCiAgICB7IngtYW16LW1ldGEtdXVpZCI6ICIxNDM2NTEyMzY1MTI3NCJ9LA0KICAgIFsic3RhcnRzLXdpdGgiLCAiJHgtYW16LW1ldGEtdGFnIiwgIiJdLA0KDQogICAgeyJ4LWFtei1jcmVkZW50aWFsIjogIkFLSUFJT1NGT0ROTjdFWEFNUExFLzIwMTMwODA2L3VzLWVhc3QtMS9zMy9hd3M0X3JlcXVlc3QifSwNCiAgICB7IngtYW16LWFsZ29yaXRobSI6ICJBV1M0LUhNQUMtU0hBMjU2In0sDQogICAgeyJ4LWFtei1kYXRlIjogIjIwMTMwODA2VDAwMDAwMFoiIH0NCiAgXQ0KfQ",
"x-amz-algorithm": "AWS4-HMAC-SHA256",
"x-amz-credential": "AKIAIOSFODNN7EXAMPLE/20130721/us-east-1/s3/aws4_request",
"x-amz-date": "20130721T201207Z",
"x-amz-signature": "733255ef022bec3f2a8701cd61d4b371f3f28c9f193a1f02279211d48d5193d7"
}
根据Amazon S3: API Reference: Authenticating Requests in Browser-Based Uploads Using POST,我认为可以安全地假设所有字符串都不会包含"
,:
或空白字符。
所以,我想我的问题是:如何将上面的字符串解析为Array
元组[(String, String)]
?