Created
February 23, 2016 22:40
-
-
Save alena1108/06882fdd03bddfbd4b27 to your computer and use it in GitHub Desktop.
readData
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (s *Server) parseData(dataStr string, obj interface{}) error { | |
type Data struct { | |
Fields interface{} `json:"fields"` | |
} | |
data := Data{} | |
bytes := []byte(dataStr) | |
if err := json.Unmarshal(bytes, &data); err != nil { | |
return err | |
} | |
fieldsM, err := json.Marshal(data.Fields) | |
if err != nil { | |
return err | |
} | |
if err = json.Unmarshal(fieldsM, &obj); err != nil { | |
return err | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment