Last active
August 25, 2019 10:29
-
-
Save mvlootman/d89df577a7fe49023a713e294600f6ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
struct weather { | |
id int | |
main string | |
description string | |
icon string | |
} | |
struct document { | |
weather []weather | |
} | |
fn main(){ | |
sub_json := '{"weather": | |
[{ | |
"id": 300, | |
"main": "Drizzle", | |
"description": "light intensity drizzle", | |
"icon": "09d" | |
}] | |
}' | |
doc := json.decode(document, sub_json) or { | |
panic('unable to parse weather') | |
} | |
for w_elem in doc.weather{ | |
println(w_elem) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment