Use standard library for JSON encoding
This commit is contained in:
parent
7f4534f03e
commit
9d97be7c15
@ -1,8 +1,9 @@
|
|||||||
package arn
|
package arn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/animenotifier/anilist"
|
"github.com/animenotifier/anilist"
|
||||||
jsoniter "github.com/json-iterator/go"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// AniListMatch ...
|
// AniListMatch ...
|
||||||
@ -13,7 +14,7 @@ type AniListMatch struct {
|
|||||||
|
|
||||||
// JSON ...
|
// JSON ...
|
||||||
func (match *AniListMatch) JSON() string {
|
func (match *AniListMatch) JSON() string {
|
||||||
b, err := jsoniter.Marshal(match)
|
b, err := json.Marshal(match)
|
||||||
PanicOnError(err)
|
PanicOnError(err)
|
||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package arn
|
package arn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/animenotifier/kitsu"
|
"github.com/animenotifier/kitsu"
|
||||||
jsoniter "github.com/json-iterator/go"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// KitsuMatch ...
|
// KitsuMatch ...
|
||||||
@ -13,7 +14,7 @@ type KitsuMatch struct {
|
|||||||
|
|
||||||
// JSON ...
|
// JSON ...
|
||||||
func (match *KitsuMatch) JSON() string {
|
func (match *KitsuMatch) JSON() string {
|
||||||
b, err := jsoniter.Marshal(match)
|
b, err := json.Marshal(match)
|
||||||
PanicOnError(err)
|
PanicOnError(err)
|
||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package arn
|
package arn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/animenotifier/mal"
|
"github.com/animenotifier/mal"
|
||||||
jsoniter "github.com/json-iterator/go"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MyAnimeListMatch ...
|
// MyAnimeListMatch ...
|
||||||
@ -13,7 +14,7 @@ type MyAnimeListMatch struct {
|
|||||||
|
|
||||||
// JSON ...
|
// JSON ...
|
||||||
func (match *MyAnimeListMatch) JSON() string {
|
func (match *MyAnimeListMatch) JSON() string {
|
||||||
b, err := jsoniter.Marshal(match)
|
b, err := json.Marshal(match)
|
||||||
PanicOnError(err)
|
PanicOnError(err)
|
||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package arn
|
package arn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
webpush "github.com/akyoto/webpush-go"
|
webpush "github.com/akyoto/webpush-go"
|
||||||
jsoniter "github.com/json-iterator/go"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// PushSubscription ...
|
// PushSubscription ...
|
||||||
@ -39,7 +39,7 @@ func (sub *PushSubscription) SendNotification(notification *PushNotification) (*
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create notification
|
// Create notification
|
||||||
data, err := jsoniter.Marshal(notification)
|
data, err := json.Marshal(notification)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package arn
|
package arn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -17,7 +18,6 @@ import (
|
|||||||
"github.com/akyoto/color"
|
"github.com/akyoto/color"
|
||||||
"github.com/animenotifier/kitsu"
|
"github.com/animenotifier/kitsu"
|
||||||
"github.com/animenotifier/mal"
|
"github.com/animenotifier/mal"
|
||||||
jsoniter "github.com/json-iterator/go"
|
|
||||||
shortid "github.com/ventu-io/go-shortid"
|
shortid "github.com/ventu-io/go-shortid"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ func AgeInYears(birthDayString string) int {
|
|||||||
|
|
||||||
// JSON turns the object into a JSON string.
|
// JSON turns the object into a JSON string.
|
||||||
func JSON(obj interface{}) string {
|
func JSON(obj interface{}) string {
|
||||||
data, err := jsoniter.Marshal(obj)
|
data, err := json.Marshal(obj)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return string(data)
|
return string(data)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package stringutils
|
package stringutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
|
||||||
"github.com/xrash/smetrics"
|
"github.com/xrash/smetrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ func PrettyPrint(obj interface{}) {
|
|||||||
// Currently, MarshalIndent doesn't support tabs.
|
// Currently, MarshalIndent doesn't support tabs.
|
||||||
// Change this back to using \t when it's implemented.
|
// Change this back to using \t when it's implemented.
|
||||||
// See: https://github.com/json-iterator/go/pull/273
|
// See: https://github.com/json-iterator/go/pull/273
|
||||||
pretty, _ := jsoniter.MarshalIndent(obj, "", " ")
|
pretty, _ := json.MarshalIndent(obj, "", " ")
|
||||||
fmt.Println(string(pretty))
|
fmt.Println(string(pretty))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user