New filters on the Home Feed, take a look!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

0
Best way to handle a JSON array of variable shaped objects?
Post Body

I'm writing a web service that filters a JSON array from from another source. The array of objects contains some common fields, that I want to filter on. It also includes a type discriminator. Depending on type they have a number of other fields that I don't need in my process, but I cannot lose when I render the output to JSON again. It would be brittle for me to try to codify each type as a struct in my application because there are dozens of possible types and they can change without my knowledge. Right now, I'm treating it as a map[string]interface{} but I'm thinking there has to be a more elegant way.

Author
User Disabled
Account Strength
0%
Disabled 5 months ago
Account Age
9 years
Verified Email
Yes
Verified Flair
No
Total Karma
2,982
Link Karma
2,169
Comment Karma
813
Profile updated: 3 days ago
Posts updated: 7 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
7 years ago