change json encoder
This commit is contained in:
		
							
								
								
									
										13
									
								
								sign.go
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								sign.go
									
									
									
									
									
								
							@@ -6,7 +6,6 @@ import (
 | 
			
		||||
	"crypto/rand"
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"encoding/hex"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"github.com/ugorji/go/codec"
 | 
			
		||||
	"hash/crc64"
 | 
			
		||||
@@ -60,10 +59,14 @@ func Format(token string) (txt string, err error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	buf := bytes.NewBuffer(nil)
 | 
			
		||||
	var handle codec.CborHandle
 | 
			
		||||
	var cHandle codec.CborHandle
 | 
			
		||||
	var jHandle codec.JsonHandle
 | 
			
		||||
	jHandle.HTMLCharsAsIs = true
 | 
			
		||||
	jHandle.MapKeyAsString = true
 | 
			
		||||
	jHandle.Indent = 4
 | 
			
		||||
 | 
			
		||||
	buf.Write(data)
 | 
			
		||||
	dec := codec.NewDecoder(buf, &handle)
 | 
			
		||||
	dec := codec.NewDecoder(buf, &cHandle)
 | 
			
		||||
 | 
			
		||||
	var td tokenData
 | 
			
		||||
	err = dec.Decode(&td)
 | 
			
		||||
@@ -79,9 +82,7 @@ func Format(token string) (txt string, err error) {
 | 
			
		||||
	buf.Reset()
 | 
			
		||||
	buf.Write([]byte("SIGNATURE=" + hex.EncodeToString(td.Signature) + "\n"))
 | 
			
		||||
 | 
			
		||||
	enc := json.NewEncoder(buf)
 | 
			
		||||
	enc.SetEscapeHTML(false)
 | 
			
		||||
	enc.SetIndent("", "\t")
 | 
			
		||||
	enc := codec.NewEncoder(buf, &jHandle)
 | 
			
		||||
	err = enc.Encode(payload)
 | 
			
		||||
	txt = buf.String()
 | 
			
		||||
	return
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user