Rust: Parse nested JSON
Mar 24, 2022
Not a whole lot new to cover here that isn't already implied from the previous parsing JSON lesson. It works exactly as you'd expect. So here's a bonus shorthand way to parse an object into a JSON structure:
use serde_json::json;fn main() {let glenn = json!({"name": "Glenn Gillen","age": 40,"phones": ["+61 448612567"],"address": {"line1": "123 Main St","state": "VIC","country": "AU"}});println!("first phone number: {}", glenn["phones"][0]);println!("state: {}", glenn["address"]["state"]);println!("{}", glenn.to_string());}
Hi, I'm Glenn! 👋 I've spent most of my career working with or at startups. I'm currently the Director of Product @ Ockam where I'm helping developers build applications and systems that are secure-by-design. It's time we started securely connecting apps, not networks.
Previously I led the Terraform product team @ HashiCorp, where we launched Terraform Cloud and set the stage for a successful IPO. Prior to that I was part of the Startup Team @ AWS, and earlier still an early employee @ Heroku. I've also invested in a couple of dozen early stage startups.
Previously I led the Terraform product team @ HashiCorp, where we launched Terraform Cloud and set the stage for a successful IPO. Prior to that I was part of the Startup Team @ AWS, and earlier still an early employee @ Heroku. I've also invested in a couple of dozen early stage startups.