]> 127.0.0.1 Git - part/.git/commitdiff
84 v0.0.6
authorqydysky <qydysky@foxmail.com>
Fri, 9 Oct 2020 23:00:12 +0000 (07:00 +0800)
committerqydysky <qydysky@foxmail.com>
Fri, 9 Oct 2020 23:00:12 +0000 (07:00 +0800)
Json.go

diff --git a/Json.go b/Json.go
index 207d387b2f1b0293f1a9240b2117f52f93c20e04..f49bd50e3666069954cc962628e780c5fab2bccb 100644 (file)
--- a/Json.go
+++ b/Json.go
@@ -65,6 +65,17 @@ func (*json) GetValFromS(Source string,key string)interface {}{
        return jq.More().Find(key)
 }
 
+func (*json) GetArrayFrom(Source interface{},key string)[]interface {}{
+       var jq *gojsonq.JSONQ
+       switch Source.(type) {
+    case string:
+               jq = gojsonq.New().FromString(Source.(string))
+       default:
+        jq = gojsonq.New().FromInterface(Source)
+    }
+       return jq.Pluck(key).([]interface{})
+}
+
 func (this *json) GetMultiValFrom(Source interface{},key []string) []interface{}{
        var jq *gojsonq.JSONQ
        switch Source.(type) {