Created
July 11, 2018 08:54
-
-
Save LaughingVzr/71b86b8a55cc9769c6c88e5c46f26ec2 to your computer and use it in GitHub Desktop.
[Golang原生json包[]interface转[]string] #golang #json
This file contains hidden or 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
// 对参数进行断言,确定类型并获取参数 | |
if targetParam, ok := params["a"].([]interface{}); ok { | |
for _, param := range targetParam { | |
switch v := param.(type) { | |
case string: | |
paramArr = append(paramArr, v) | |
case float64: | |
paramArr = append(paramArr, strconv.FormatFloat(v, 'f', 0, 64)) | |
case int64: | |
paramArr = append(paramArr, strconv.FormatInt(v, 10)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment