Sha256: 3b04a362a650eb8082df764251f4772e0ba95fad750c2737cb059434512f1e6e

Contents?: true

Size: 659 Bytes

Versions: 2

Compression:

Stored size: 659 Bytes

Contents

require_relative 'JSON_parser'

# Create a JSON parser object
parser = JSONParser.new 

# Parse the input file with name given in command-line
if ARGV.empty?
  msg = <<-END_MSG
Command-line symtax:
  ruby #{__FILE__} filename
  where:
    filename is the name of a JSON file
    
  Example:
  ruby #{__FILE__} sample01.json
END_MSG
  puts msg
  exit(1)
end
file_name = ARGV[0]
result = parser.parse_file(file_name) # result object contains parse details

unless result.success?
  # Stop if the parse failed...
  puts "Parsing of '#{file_name}' failed"
  exit(1)
end

# Generate a parse forest from the parse result
pforest = result.parse_forest
# End of file

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rley-0.3.12 examples/data_formats/JSON/JSON_demo.rb
rley-0.3.11 examples/data_formats/JSON/demo_json.rb