This is a created article in which the information may have evolved or changed.
Go parse JSON format string type Info struct{ Name string Age int Address string} to parse the JSON format string into a struct, simply pass the struct object to the JSON . Unmarshal () function Jsonstr: = ' {' name ': ' Yang ', ' age ': ' Address ': ' Shenzhen '} ' Var myinfo infojson.unmarshal ([]byte ( JSONSTR), &myinfo) Description: In the declaration structure there are two places to note, the following explanation illustrates the first type Info struct{ Name string Age int Address The string} variable name must be the same as the JSON string name, and the first letter uppercase, because in the go language, the first letter capitalized to represent global variables, the same reason, Age,address is the same as the second type of Info struct{ myName Stirng ' JSON: ' name ' ' myAge int ' json: ' Age ' ' myAddress string ' JSON: ' Shenzhen ' '} This way, struct variable names can be arbitrarily defined, but must be followed by ' JSON: "Name" and so on, "name" is the corresponding key in the JSON string, myname store the value corresponding to the key can also parse the JSON string to some structure