// MarshalJSONWithOrder return keeped order json
MarshalJSONWithOrder return keeped order json
// MarshalJSONWithOrder return keeped order json
func (m *HistogramMetrics) MarshalJSONWithOrder() ([]byte, error) {
	sortKeys := make([]string, 0)
	agg := m.Aggregate()
	for k := range agg {
		sortKeys = append(sortKeys, k)
	}
	sort.Strings(sortKeys)
	var buf bytes.Buffer
	buf.Write([]byte("{"))
	for k, v := range sortKeys {
		if k != 0 {
			buf.Write([]byte(","))
		}
		value, err := agg[v].MarshalJSON()
		if err != nil {
			return nil, err
		}
		buf.Write([]byte(fmt.Sprintf("%q:%s", v, value)))
	}
	buf.Write([]byte("}"))
	return buf.Bytes(), nil
}
func ( m * HistogramMetrics ) MarshalJSONWithOrder ( ) ( [ ] byte , error ) { sortKeys := make ( [ ] string , 0 ) agg := m . Aggregate ( ) for k := range agg { sortKeys = append ( sortKeys , k ) } sort . Strings ( sortKeys ) var buf bytes . Buffer buf . Write ( [ ] byte ( " " ) ) for k , v := range sortKeys { if k != 0 { buf . Write ( [ ] byte ( " " ) ) } value , err := agg [ v ] . MarshalJSON ( ) if err != nil { return nil , err } buf . Write ( [ ] byte ( fmt . Sprintf ( " " , v , value ) ) ) } buf . Write ( [ ] byte ( " " ) ) return buf . Bytes ( ) , nil }
MarshalJSONWithOrder return keeped order json
MarshalJSONWithOrder return keeped order json
// create json