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

encoding/json: No way to unmarshal empty string field into struct #29760

darkfeline opened this issue Jan 16, 2019 · 2 comments


None yet
3 participants
Copy link

commented Jan 16, 2019

There doesn't appear to be a way to unmarshal a JSON field with an empty string key into a struct.

For example

package main

import (

func main() {
	data := []byte(`{"": "foo", "spam": "egg"}`)
	var obj struct {
		Thing string `json:""`
		Spam  string `json:"spam"`
	json.Unmarshal(data, &obj)
	fmt.Printf("%#v", obj)

This comment has been minimized.

Copy link

commented Jan 16, 2019

Duplicate of #22518


This comment has been minimized.

Copy link

commented Jan 16, 2019


@agnivade agnivade closed this Jan 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.