5c1e8e42 by Bill Davis

Reworked implementation to not return encoded json

1 parent ca3e7568
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 package toolbox 15 package toolbox
16 16
17 import ( 17 import (
18 "encoding/json"
19 "fmt" 18 "fmt"
20 "sync" 19 "sync"
21 "time" 20 "time"
...@@ -112,11 +111,7 @@ func (m *UrlMap) GetMap() map[string]interface{} { ...@@ -112,11 +111,7 @@ func (m *UrlMap) GetMap() map[string]interface{} {
112 return content 111 return content
113 } 112 }
114 113
115 func (m *UrlMap) GetMapJSON() ([]byte, error) { 114 func (m *UrlMap) GetMapData() []map[string]interface{} {
116 return json.Marshal(m)
117 }
118
119 func (m UrlMap) MarshalJSON() ([]byte, error) {
120 115
121 resultLists := make([]map[string]interface{}, 0) 116 resultLists := make([]map[string]interface{}, 0)
122 117
...@@ -134,7 +129,7 @@ func (m UrlMap) MarshalJSON() ([]byte, error) { ...@@ -134,7 +129,7 @@ func (m UrlMap) MarshalJSON() ([]byte, error) {
134 resultLists = append(resultLists, result) 129 resultLists = append(resultLists, result)
135 } 130 }
136 } 131 }
137 return json.Marshal(resultLists) 132 return resultLists
138 } 133 }
139 134
140 // global statistics data map 135 // global statistics data map
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 package toolbox 15 package toolbox
16 16
17 import ( 17 import (
18 "encoding/json"
18 "testing" 19 "testing"
19 "time" 20 "time"
20 ) 21 )
...@@ -29,9 +30,11 @@ func TestStatics(t *testing.T) { ...@@ -29,9 +30,11 @@ func TestStatics(t *testing.T) {
29 StatisticsMap.AddStatistics("DELETE", "/api/user", "&admin.user", time.Duration(1400)) 30 StatisticsMap.AddStatistics("DELETE", "/api/user", "&admin.user", time.Duration(1400))
30 t.Log(StatisticsMap.GetMap()) 31 t.Log(StatisticsMap.GetMap())
31 32
32 jsonString, err := StatisticsMap.GetMapJSON() 33 data := StatisticsMap.GetMapData()
34 b, err := json.Marshal(data)
33 if err != nil { 35 if err != nil {
34 t.Errorf(err.Error()) 36 t.Errorf(err.Error())
35 } 37 }
36 t.Log(string(jsonString)) 38
39 t.Log(string(b))
37 } 40 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!