David Bureš on Nostr: Hey guys, a quick Swift question about arrays. Suppose I have an array like this: ...
Hey guys, a quick Swift question about arrays.
Suppose I have an array like this:
`[["statistic": "account name", "value": " SomeAccount"], ["value": "2023-06-23 16:44:49 UTC", "statistic": "export time“]]`
And I want to transform it into a dictionary like this:
[
"account name": "SomeAccount",
"export time": "2023-06-23 16:44:49 UTC"
]
Basically, take every „statistic“ and turn it into a key, and turn every „value“ into a value for that key.
Any ideas?
#swift
Published at
2023-06-25 10:45:21Event JSON
{
"id": "f5ebd7a40cb42387dace1a4ae549c183eafe3880ef8454144c2e62c68b9a525f",
"pubkey": "17ca545e6a302644a7898dc6862e512bb987c80b13d07bf3f5c2448e24db9b5f",
"created_at": 1687689921,
"kind": 1,
"tags": [
[
"t",
"swift"
],
[
"mostr",
"https://mstdn.social/users/davidbures/statuses/110604446712680418"
]
],
"content": "Hey guys, a quick Swift question about arrays.\n\nSuppose I have an array like this:\n`[[\"statistic\": \"account name\", \"value\": \" SomeAccount\"], [\"value\": \"2023-06-23 16:44:49 UTC\", \"statistic\": \"export time“]]`\n\nAnd I want to transform it into a dictionary like this:\n[\n\"account name\": \"SomeAccount\",\n\"export time\": \"2023-06-23 16:44:49 UTC\"\n]\n\nBasically, take every „statistic“ and turn it into a key, and turn every „value“ into a value for that key.\n\nAny ideas?\n\n#swift",
"sig": "bd2c051fbcb0fbf0c1026e16daded746eb401b9f016d9e2c621dc612c604507c7e463fa9818a2f3d528c9cd4adf0ffc5f021f49106682889d42bf68e5dd671b4"
}