Module: PinchHitter::Message::Json

Included in:
ContentType, MessageStore
Defined in:
lib/pinch_hitter/message/json.rb

Instance Method Summary collapse

Instance Method Details

#json_message(file, overrides = {}) ⇒ Object



3
4
5
6
# File 'lib/pinch_hitter/message/json.rb', line 3

def json_message(file, overrides={})
  json_file = load_json_file file
  replace_json json_file, overrides
end

#valid_json?(json) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
# File 'lib/pinch_hitter/message/json.rb', line 8

def valid_json?(json)
  begin
    JSON.parse json
    return true
  rescue
    return false
  end
end