What does Go's JSON package mean when it refers to Marshal?

huangapple go评论84阅读模式
英文:

What does Go's JSON package mean when it refers to Marshal?

问题

在这个上下文中,Marshal、Unmarshal和Marshaler是与编码和解码JSON数据相关的术语。

  • Marshal:将Go语言中的数据结构转换为JSON格式的字符串。在Go语言中,可以使用json.Marshal()函数来执行此操作。

  • Unmarshal:将JSON格式的字符串转换为Go语言中的数据结构。在Go语言中,可以使用json.Unmarshal()函数来执行此操作。

  • Marshaler:是一个接口类型,用于自定义JSON编码的行为。如果一个类型实现了json.Marshaler接口,那么在将该类型的实例转换为JSON格式时,将会调用该类型的MarshalJSON()方法。

你可以在这个链接中找到更多关于JSON编码和解码的信息:http://golang.org/pkg/encoding/json/

英文:

http://golang.org/pkg/encoding/json/

Marshal, unmarshal, marshaler. Very confused. Never heard of such terms in this context.

答案1

得分: 24

从维基百科关于Marshalling的文章中,

> Marshalling(有时拼写为marshaling,只有一个l)是将对象的内存表示转换为适合存储或传输的数据格式的过程。

英文:

From wikipedia article on Marshalling,

> Marshalling (sometimes spelled marshaling with a single l) is the
> process of transforming the memory representation of an object to a
> data format suitable for storage or transmission.

huangapple
  • 本文由 发表于 2013年11月5日 09:31:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/19780494.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定