Class: PhusionPassenger::Utils::JSON
- Extended by:
- Forwardable, Generator
- Defined in:
- lib/phusion_passenger/utils/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.
58 59 60 |
# File 'lib/phusion_passenger/utils/json.rb', line 58 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.
53 54 55 |
# File 'lib/phusion_passenger/utils/json.rb', line 53 def scanner @scanner end |
Class Method Details
.parse(data) ⇒ Object
43 |
# File 'lib/phusion_passenger/utils/json.rb', line 43 def self.parse(data) new(data).parse end |
Instance Method Details
#parse ⇒ Object
62 63 64 65 |
# File 'lib/phusion_passenger/utils/json.rb', line 62 def parse space object end |