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



8
9
10
11
12
# File 'lib/jwt/json.rb', line 8

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

#encode_json(raw) ⇒ Object



14
15
16
# File 'lib/jwt/json.rb', line 14

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