Skip to content

Commit

Permalink
deprecate useless json functions
Browse files Browse the repository at this point in the history
  • Loading branch information
xgfone committed May 11, 2024
1 parent e2df81e commit 493ff46
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
35 changes: 35 additions & 0 deletions helper/deprecated_json.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2024 xgfone
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package helper

import (
"bytes"
"encoding/json"
"strings"
)

// DecodeJSONFromString decodes the json raw string s into dst.
//
// DEPRECATED!!!
func DecodeJSONFromString(dst interface{}, s string) error {
return json.NewDecoder(strings.NewReader(s)).Decode(dst)
}

// DecodeJSONFromBytes decodes the json raw bytes s into dst.
//
// DEPRECATED!!!
func DecodeJSONFromBytes(dst interface{}, b []byte) error {
return json.NewDecoder(bytes.NewReader(b)).Decode(dst)
}
11 changes: 0 additions & 11 deletions helper/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,9 @@ import (
"bytes"
"encoding/json"
"io"
"strings"
"sync"
)

// DecodeJSONFromString decodes the json raw string s into dst.
func DecodeJSONFromString(dst interface{}, s string) error {
return json.NewDecoder(strings.NewReader(s)).Decode(dst)
}

// DecodeJSONFromBytes decodes the json raw bytes s into dst.
func DecodeJSONFromBytes(dst interface{}, b []byte) error {
return json.NewDecoder(bytes.NewReader(b)).Decode(dst)
}

// EncodeJSON encodes the value by json into w.
//
// NOTICE: it does not escape the problematic HTML characters.
Expand Down

0 comments on commit 493ff46

Please sign in to comment.