Class: UnionStationHooks::SimpleJSON::JSON
- Inherits:
-
Object
- Object
- UnionStationHooks::SimpleJSON::JSON
- Extended by:
- Forwardable, Generator
- Defined in:
- lib/union_station_hooks_core/simple_json.rb
Overview
Usage:
JSON.parse(json_string) => Array/Hash
JSON.generate(object) => json string
Run tests by executing this file directly. Pipe standard input to the script to have it parsed as JSON and to display the result in Ruby.
Defined Under Namespace
Modules: Generator
Constant Summary collapse
- WSP =
/(\s|\/\/.*?\n|\/\*.*?\*\/)+/m
- OBJ =
/[{\[]/- HEN =
/\}/- AEN =
/\]/- COL =
/\s*:\s*/- KEY =
/\s*,\s*/- NUM =
/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/- BOL =
/true|false/- NUL =
/null/
Instance Attribute Summary collapse
-
#scanner ⇒ Object
(also: #s)
readonly
Returns the value of attribute scanner.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ JSON
constructor
A new instance of JSON.
- #parse ⇒ Object
Methods included from Generator
Constructor Details
#initialize(data) ⇒ JSON
Returns a new instance of JSON.
59 60 61 |
# File 'lib/union_station_hooks_core/simple_json.rb', line 59 def initialize data @scanner = StringScanner.new data.to_s end |
Instance Attribute Details
#scanner ⇒ Object (readonly) Also known as: s
Returns the value of attribute scanner.
54 55 56 |
# File 'lib/union_station_hooks_core/simple_json.rb', line 54 def scanner @scanner end |
Class Method Details
.parse(data) ⇒ Object
44 |
# File 'lib/union_station_hooks_core/simple_json.rb', line 44 def self.parse(data) new(data).parse end |
Instance Method Details
#parse ⇒ Object
63 64 65 66 |
# File 'lib/union_station_hooks_core/simple_json.rb', line 63 def parse space object end |