How golang uses private fields
Editor to share with you how golang uses private fields, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Use private fields
Go's standard library supports only public's field. Jsoniter has additional support for private's field. Use SupportPrivateFields () to turn on the switch.
Import "github.com/json-iterator/go/extra" extra.SupportPrivateFields () type TestObject struct {field1 string} obj: = TestObject {} jsoniter.UnmarshalFromString (`{"field1": "Hello"}`, & obj) should.Equal ("Hello", obj.field1) these are all the contents of the article "how golang uses private fields". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!