From aef835e62056764c2558ac9d72a525425a2384c4 Mon Sep 17 00:00:00 2001 From: pawlaczyk Date: Sun, 13 Jan 2019 05:49:56 +0100 Subject: [PATCH] map[string]interface dobralam sie do wartosci --- backend/connector_couchdb.go | 49 +++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/backend/connector_couchdb.go b/backend/connector_couchdb.go index f08adce..371703b 100644 --- a/backend/connector_couchdb.go +++ b/backend/connector_couchdb.go @@ -105,24 +105,39 @@ func getAllDoc() { keys := reflect.ValueOf(generic).MapKeys() fmt.Println("KEYS: ", keys) - // for k, v := range generic { - // if k == "rows" { - // switch val := v.(type) { - // // case string: - // // fmt.Println(k, "is string", val) - // // case int: - // // fmt.Println(k, "is int", val) - // case []interface{}: - // fmt.Println(k, "is an array") - // for _, v := range val { - // fmt.Println(v) //, i) + for k, v := range generic { + if k == "rows" { + switch val := v.(type) { + // case string: + // fmt.Println(k, "is string", val) + // case int: + // fmt.Println(k, "is int", val) + case []interface{}: + fmt.Println(k, "is an array") + for _, v := range val { + // fmt.Println(v) //, i) + // fmt.Println(reflect.TypeOf(v)) + // fmt.Println(i) + mResult := v.(map[string]interface{}) + // fmt.Println(mResult["doc"]) + // fmt.Println(reflect.TypeOf(mResult["doc"])) - // } - // // default: - // // fmt.Println(k, "is unknown type") - // } - // } - // } + mResult2 := mResult["doc"].(map[string]interface{}) + // fmt.Println(reflect.TypeOf(mResult2)) + fmt.Println(mResult2["Text"]) + fmt.Println(mResult2["Timestamp"]) + fmt.Println(mResult2["_id"]) + fmt.Println(mResult2["blank"]) + + // mResult2 := mResult.(map[string]interface{}) + // fmt.Println(mResult2["Timestamp"]) + + } + // default: + // fmt.Println(k, "is unknown type") + } + } + } // fmt.Println("Zmienna: ", zmiena) }