mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 03:00:55 +00:00
Reworked implementation to not return encoded json
This commit is contained in:
parent
ca3e7568a1
commit
5c1e8e42b9
@ -15,7 +15,6 @@
|
|||||||
package toolbox
|
package toolbox
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -112,11 +111,7 @@ func (m *UrlMap) GetMap() map[string]interface{} {
|
|||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *UrlMap) GetMapJSON() ([]byte, error) {
|
func (m *UrlMap) GetMapData() []map[string]interface{} {
|
||||||
return json.Marshal(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m UrlMap) MarshalJSON() ([]byte, error) {
|
|
||||||
|
|
||||||
resultLists := make([]map[string]interface{}, 0)
|
resultLists := make([]map[string]interface{}, 0)
|
||||||
|
|
||||||
@ -134,7 +129,7 @@ func (m UrlMap) MarshalJSON() ([]byte, error) {
|
|||||||
resultLists = append(resultLists, result)
|
resultLists = append(resultLists, result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return json.Marshal(resultLists)
|
return resultLists
|
||||||
}
|
}
|
||||||
|
|
||||||
// global statistics data map
|
// global statistics data map
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
package toolbox
|
package toolbox
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -29,9 +30,11 @@ func TestStatics(t *testing.T) {
|
|||||||
StatisticsMap.AddStatistics("DELETE", "/api/user", "&admin.user", time.Duration(1400))
|
StatisticsMap.AddStatistics("DELETE", "/api/user", "&admin.user", time.Duration(1400))
|
||||||
t.Log(StatisticsMap.GetMap())
|
t.Log(StatisticsMap.GetMap())
|
||||||
|
|
||||||
jsonString, err := StatisticsMap.GetMapJSON()
|
data := StatisticsMap.GetMapData()
|
||||||
|
b, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf(err.Error())
|
t.Errorf(err.Error())
|
||||||
}
|
}
|
||||||
t.Log(string(jsonString))
|
|
||||||
|
t.Log(string(b))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user