
Nim: Object to JSON
Turning a data structure into JSON is incredibly easy in Nim:
import json
type
Person = object
first: string
last: string
var p = Person(first: "Glenn", last: "Gillen")
echo(%p)
Where the %
macro/operator is shorthand from the json
module for converting to JSON. There’s also
the %*
macro which can be used for assigning an object directly into a JSON data structure:
import json
let obj = %* { "first_name": "glenn", "last_name": "gillen" }
echo $obj
Published: 21/03/2022
Hi, I'm Glenn! 👋
I've spent most of my career working with or at startups. You'll usually find me working in Product leadership roles, on an advisory board, or maybe as an early investor.
I've been the VP of Product & GTM @ Ockam. I led the Terraform product team @ HashiCorp, where we launched Terraform 1.0, Terraform Cloud, and a whole host of amazing capabilities that 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.
I've spent most of my career working with or at startups. You'll usually find me working in Product leadership roles, on an advisory board, or maybe as an early investor.
I've been the VP of Product & GTM @ Ockam. I led the Terraform product team @ HashiCorp, where we launched Terraform 1.0, Terraform Cloud, and a whole host of amazing capabilities that 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.