RSSAmplifier

narf.zone · Dec 29, 2024

Write Your Own json.Unmarshal

0
Sign in to vote or save

This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.

I had a recent situation where I needed to populate an existing struct with values, similar to the way json.Unmarshal works. These values would come from various sources, like URL query parameters, form data, path variables, or something along those lines. To give an example, I needed to map a URL like /newStudent?name=Albert&age=16&city=Zurich onto a Golang struct like this: type Student struct {…

Read on stuff.narf.zone

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.