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

descendents, extension

Class Method Details

.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



73
# File 'lib/parsers.rb', line 73

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



66
# File 'lib/parsers.rb', line 66

def self.parse(text); JSON.parse text, symbolize_names: true; end