Class: JSON
- Inherits:
-
Object
- Object
- JSON
- Extended by:
- Forwardable, Generator
- Defined in:
- lib/jtag/stupid_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+/- 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.
51 52 53 |
# File 'lib/jtag/stupid_json.rb', line 51 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.
46 47 48 |
# File 'lib/jtag/stupid_json.rb', line 46 def scanner @scanner end |
Class Method Details
.parse(data) ⇒ Object
36 |
# File 'lib/jtag/stupid_json.rb', line 36 def self.parse(data) new(data).parse end |
Instance Method Details
#parse ⇒ Object
55 56 57 58 |
# File 'lib/jtag/stupid_json.rb', line 55 def parse space object end |