Skip to content

Instantly share code, notes, and snippets.

@mvlootman
Last active August 25, 2019 10:29
Show Gist options
  • Save mvlootman/d89df577a7fe49023a713e294600f6ee to your computer and use it in GitHub Desktop.
Save mvlootman/d89df577a7fe49023a713e294600f6ee to your computer and use it in GitHub Desktop.
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