Module: JsonStructMapper
- Defined in:
- lib/json_struct_mapper.rb,
lib/json_struct_mapper/errors.rb,
lib/json_struct_mapper/version.rb,
lib/json_struct_mapper/converter.rb
Overview
JsonStructMapper provides an easy way to convert JSON data into Ruby Struct objects
Defined Under Namespace
Classes: Converter, Error, FileNotFoundError, InvalidJSONError, InvalidKeyError
Constant Summary collapse
- VERSION =
'0.2.0'
Class Method Summary collapse
-
.from_file(file_path, key = nil) ⇒ Object
Convenience method to create a converter from a file.
-
.from_hash(hash) ⇒ Object
Convenience method to create a converter from a hash.
-
.from_json(json_string, key = nil) ⇒ Object
Convenience method to create a converter from a JSON string.
-
.from_json_file_to_template(file_path, key = nil) ⇒ Object
Convenience method to create a converter from a JSON file and creating template of it.
Class Method Details
.from_file(file_path, key = nil) ⇒ Object
Convenience method to create a converter from a file
11 12 13 |
# File 'lib/json_struct_mapper.rb', line 11 def from_file(file_path, key = nil) Converter.new(file_path, key) end |
.from_hash(hash) ⇒ Object
Convenience method to create a converter from a hash
16 17 18 |
# File 'lib/json_struct_mapper.rb', line 16 def from_hash(hash) Converter.from_hash(hash) end |
.from_json(json_string, key = nil) ⇒ Object
Convenience method to create a converter from a JSON string
21 22 23 |
# File 'lib/json_struct_mapper.rb', line 21 def from_json(json_string, key = nil) Converter.from_json(json_string, key) end |
.from_json_file_to_template(file_path, key = nil) ⇒ Object
Convenience method to create a converter from a JSON file and creating template of it
26 27 28 |
# File 'lib/json_struct_mapper.rb', line 26 def from_json_file_to_template(file_path, key = nil) Converter.from_json_file_to_template(file_path, key) end |