lib/entityjs/parsers/parse_xml.rb in entityjs-0.3.0 vs lib/entityjs/parsers/parse_xml.rb in entityjs-0.3.1

- old
+ new

@@ -1,10 +1,13 @@ module Entityjs class ParseXML def self.parse_to_hash(contents) + if contents.nil? || contents.empty? + return '{}' + end #might need different transfomration #remove header contents = contents.gsub(/<\?xml.*\?>/, '') #convert to hash @@ -17,22 +20,30 @@ break end end return contents - end def self.parse(contents) + if contents.nil? || contents.empty? + return '{}' + end + if contents.is_a? String contents = self.parse_to_hash(contents) end #to string contents = contents.to_json #remove @ - return contents.gsub('"@','"') + contents = contents.gsub('"@','"') + + + #transform string-numbers into numbers + + return contents.gsub(/"[0-9\.]*"/){|s| s[1..-2] } end end end \ No newline at end of file