Module: SON
- Defined in:
- lib/json/next/parser/son.rb
Constant Summary collapse
- DOUBLE_QUOTE =
JSON::Next::DOUBLE_QUOTE
- SHELL_COMMENT =
JSON::Next::SHELL_COMMENT
Class Method Summary collapse
Class Method Details
.convert(text) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/json/next/parser/son.rb', line 31 def self.convert( text ) # text is the SON string to convert. text = strip_comments( text ) ## pass 1 text = JSON::Next::Commata.convert( text ) ## pass 2 - auto-add (missing optional) commas text end |
.parse(text) ⇒ Object
41 42 43 |
# File 'lib/json/next/parser/son.rb', line 41 def self.parse( text ) JSON.parse( self.convert( text ) ) end |
.strip_comments(text) ⇒ Object
pass 1
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/json/next/parser/son.rb', line 16 def self.strip_comments( text ) ## pass 1 text.gsub( /#{DOUBLE_QUOTE}|#{SHELL_COMMENT}/ox ) do |match| ## puts "match: >>#{match}<< : #{match.class.name}" if match[0] == ?# ## comments start with # ## puts "!!! removing comments" '' ## remove / strip comments else match end end end |