Module: SyncwiseApi::ServiceUtils::Parsers::JSON

Defined in:
lib/syncwise_api/service_utils/parsers/json.rb

Class Method Summary collapse

Class Method Details

.parse(json_string) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/syncwise_api/service_utils/parsers/json.rb', line 8

def parse(json_string)

  recursive_parse = true
  parsed = ''

  if !json_string.blank? && json_string.is_a?(String)
    begin
      parsed = Yajl::Parser.parse(json_string)
      parsed = parsed.symbolize_keys if parsed.is_a?(Hash)
    rescue => e
      SyncwiseApi::Errors::JSONParseError.new(e)
    end
  end

  while recursive_parse
    recursive_parse = sub_parse!(parsed)
  end

  parsed
end