mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 09:48:32 +02:00
fix(json): ensure valid json
This commit is contained in:
@@ -2,7 +2,6 @@ package jsonstore
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"maps"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -114,7 +113,7 @@ func (s *MapStore[VT]) Initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s MapStore[VT]) MarshalJSON() ([]byte, error) {
|
func (s MapStore[VT]) MarshalJSON() ([]byte, error) {
|
||||||
return sonic.Marshal(maps.Collect(s.Range))
|
return sonic.Marshal(xsync.ToPlainMap(s.Map))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MapStore[VT]) UnmarshalJSON(data []byte) error {
|
func (s *MapStore[VT]) UnmarshalJSON(data []byte) error {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package nettypes
|
|||||||
import (
|
import (
|
||||||
urlPkg "net/url"
|
urlPkg "net/url"
|
||||||
|
|
||||||
|
"github.com/bytedance/sonic"
|
||||||
"github.com/yusing/godoxy/internal/utils"
|
"github.com/yusing/godoxy/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ func (u *URL) MarshalJSON() (text []byte, err error) {
|
|||||||
if u == nil {
|
if u == nil {
|
||||||
return []byte("null"), nil
|
return []byte("null"), nil
|
||||||
}
|
}
|
||||||
return []byte("\"" + u.URL.String() + "\""), nil
|
return sonic.Marshal(u.URL.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *URL) Equals(other *URL) bool {
|
func (u *URL) Equals(other *URL) bool {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ type (
|
|||||||
LastSeenStr string `json:"lastSeenStr"`
|
LastSeenStr string `json:"lastSeenStr"`
|
||||||
Detail string `json:"detail"`
|
Detail string `json:"detail"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Extra *HealthExtra `json:"extra" extensions:"x-nullable"`
|
Extra *HealthExtra `json:"extra,omitempty" extensions:"x-nullable"`
|
||||||
} // @name HealthJSON
|
} // @name HealthJSON
|
||||||
|
|
||||||
HealthJSONRepr struct {
|
HealthJSONRepr struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user