Module: JsonUtils

Defined in:
lib/seqtrimnext/utils/json_utils.rb

Overview

SCBI - dariogf <[email protected]>


Version: 0.1 - 04/2009

Usage: require “utils/json_utils”

Fasta utilities

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_json_data(file_path) ⇒ Object


get json data




34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/seqtrimnext/utils/json_utils.rb', line 34

def self.get_json_data(file_path)
  file1 = File.open(file_path)
  text = file1.read
  file1.close

  # wipe text
  text=text.grep(/^\s*[^#]/).to_s

  # decode json
  data = JSON.parse(text)

  return data
end

Instance Method Details

#from_jsonObject



25
26
27
# File 'lib/seqtrimnext/utils/json_utils.rb', line 25

def from_json
     return JSON.parse(self)
end

#to_pretty_jsonObject



20
21
22
# File 'lib/seqtrimnext/utils/json_utils.rb', line 20

def to_pretty_json
  return JSON.pretty_generate(self)
end