Home > other >  Golang how to convert the map key is struct "json"
Golang how to convert the map key is struct "json"

Time:03-20

Golang how to convert the map key is struct "json"

 
{
"A map" : {
{
"Name", "js",
"Age" : 18
}, {
"Id" : 10,
"Port" : 1234
}
}
}


Convert

 
Type ST2 struct {
Id int ` json: "Id" `
The Port int ` json: "Port" `
}

Type ST1 struct {
The Name string ` json: "Name" `
The Age int ` json: "Age" `
}

Type ST struct {
Map a Map/ST1 ST2 ` json: "Map" `
}


In short, received such a strange format "json", normal analysis method must not line, don't know what there are no other libraries can use
  • Related