I have some questions regarding the differences between JSON Encoding and JSON Marshalling.
Here is my understanding so far:
Encoding takes any data type as input, store in the stream type object
Marshal takes any data type as input, store in the byte slice type object
However, I am wondering the advantage for each of them, and their use cases. If the data will be transfer to the byte slice at the end, will it make any difference by using the encoding method? Also, for marshalling, if I want to transfer different type into byte slice, is it recommended to use marshal for doing that?
Thank you for your help. I have another question about it. For json.Marshal, is its purpose to transfer any data type into byte slice? For example, in general, I want to transfer a data structure into string format, is it appropriate or recommended to directly use json.Marshal?