Class: JSONom::JSONParser

Inherits:
Object show all
Defined in:
lib/jsonom/json_parser.rb

Class Method Summary collapse

Class Method Details

.debug(filename = nil, propertyname = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jsonom/json_parser.rb', line 5

def self.debug(filename = nil, propertyname = nil)
	if(filename == nil)
		return
	end

	file_lines = []

	file = File.new(File.join(Dir.pwd, filename), "r")
	while (line = file.gets)
		file_lines << line
	end
	file.close

	file_data = file_lines.join("\n")

	file_struct = JSON.parse(file_data)

	thing = file_struct

	if(propertyname == nil)
	else
		propertynames = propertyname.split(".")

		propertynames.each_with_index do |property|
			thing = thing[property]
		end
	end

	puts JSON.dump(thing)
end