Class: Roject::Parsers::JSONParser
Overview
Parses JSON files
Author: Anshul Kharbanda Created: 7 - 11 - 2016
Constant Summary
Constants inherited from Parser
Class Method Summary collapse
-
.extensions ⇒ Object
Returns the extensions supported for JSON.
-
.format(hash) ⇒ Object
Returns the given hash formatted to pretty json.
-
.parse(text) ⇒ Object
Parses the given json text into a hash.
Methods inherited from Parser
Class Method Details
.extensions ⇒ Object
Returns the extensions supported for JSON
Return: the extensions supported for JSON
83 |
# File 'lib/parsers.rb', line 83 def self.extensions; [".json"]; end |
.format(hash) ⇒ Object
Returns the given hash formatted to pretty json
Parameter: hash - the hash to format
Return: the given hash formatted to pretty json
97 |
# File 'lib/parsers.rb', line 97 def self.format(hash); JSON.pretty_generate hash, indent: "\t"; end |
.parse(text) ⇒ Object
Parses the given json text into a hash
Parameter: text - the json text to parse
Return: the hash parsed from the text
90 |
# File 'lib/parsers.rb', line 90 def self.parse(text); JSON.parse text, symbolize_names: true; end |