Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use interface{} (or map[string]interface{}) instead of string for json content #101

Closed
didiladi opened this issue Dec 21, 2020 · 0 comments · Fixed by #150
Closed

Use interface{} (or map[string]interface{}) instead of string for json content #101

didiladi opened this issue Dec 21, 2020 · 0 comments · Fixed by #150
Labels
discussion Discussion about new features and improvements

Comments

@didiladi
Copy link
Contributor

@patrickpichler gave an awesome feedback here:

Why do we unmarshal the json as a string?
This seems a bit odd to me. Wouldn't something likeinterface{} be better?

Describe the solution you'd like
Replace the json string with interface{} or map[string]interface{}. This makes the extraction of elements easier, and its more efficient. This makes the following possible:

var result map[string]interface{}
json.Unmarshal([]byte(empJson), &result)

stuff := result["stuff"].(map[string]interface{})
foo := stuff["foo"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion about new features and improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant