Module: JWT::Json

Included in:
JWT
Defined in:
lib/jwt/json.rb

Overview

JSON fallback implementation or ruby 1.8.x

Instance Method Summary collapse

Instance Method Details

#decode_json(encoded) ⇒ Object



6
7
8
9
10
# File 'lib/jwt/json.rb', line 6

def decode_json(encoded)
  JSON.parse(encoded)
rescue JSON::ParserError
  raise JWT::DecodeError, 'Invalid segment encoding'
end

#encode_json(raw) ⇒ Object



12
13
14
# File 'lib/jwt/json.rb', line 12

def encode_json(raw)
  JSON.generate(raw)
end