Managing JSON data

JSON is the acronym for JavaScript Object Notation and, like the name implies, it's natively JavaScript. It has become very popular and it's the most used format for communication today. Go has very good support for JSON serialization/deserialization with the JSON package that does most of the dirty work for you. First of all, there are two concepts to learn when working with JSON:

  • Marshal: When you marshal an instance of a structure or object, you are converting it to its JSON counterpart.
  • Unmarshal: When you are unmarshaling some data, in the form of an array of bytes, you are trying to convert some JSON-expected-data to a known struct or object. You can also unmarshal to a map[string]interface{} in a fast but not very safe ...

Get Go: Design Patterns for Real-World Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.