func (c Claims) MarshalJSON() ([]byte, error) {
	if c == nil || len(c) == 0 {
		return nil, nil
	}
	b, err := json.Marshal(map[string]interface{}(c))
	if err != nil {
		return nil, err
	}
	return jose.EncodeEscape(b), nil
}
MarshalJSON implements json.Marshaler for Claims.
package jwt
import (
	"encoding/json"
	"github.com/SermoDigital/jose"
)
type Claims map[string]interface{}
func (c Claims) Validate(now, expLeeway, nbfLeeway int64) error {
	if exp, ok := c.expiration(); ok {
		if !within(exp, expLeeway, now) {
			return ErrTokenIsExpired
		}
	}
	if nbf, ok := c.notBefore(); ok {
		if !within(nbf, nbfLeeway, now) {
			return ErrTokenNotYetValid
		}
	}
	return nil
}
func (c Claims) expiration() (int64, bool) {
	v, ok := c.Get("exp").(int64)
	return v, ok
}
func (c Claims) notBefore() (int64, bool) {
	v, ok := c.Get("nbf").(int64)
	return v, ok
}
func within(cur, delta, max int64) bool {
	return cur+delta < max || cur-delta < max
}
func (c Claims) Get(key string) interface{} {
	if c == nil {
		return nil
	}
	return c[key]
}
func (c Claims) Set(key string, val interface{}) {
	c[key] = val
}
func (c Claims) Del(key string) {
	delete(c, key)
}
func (c Claims) Has(key string) bool {
	_, ok := c[key]
	return ok
}