Class: Roject::Parsers::JSONParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/parsers.rb

Overview

Parses JSON files

Author: Anshul Kharbanda Created: 7 - 11 - 2016

Constant Summary

Constants inherited from Parser

Parser::PARSER_REGEX

Class Method Summary collapse

Methods inherited from Parser

descendants, for_filename?

Class Method Details

.extensionsObject

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