Module: KazeClient::JsonUtils
- Defined in:
- lib/kaze_client/json_utils.rb
Overview
Utility methods to interact with JSON data
Class Method Summary collapse
-
.fetch_node(json, path) ⇒ Object?
Fetch a node in given JSON.
-
.fetch_nodes(json, path) ⇒ Array
Fetch nodes in given JSON.
Class Method Details
.fetch_node(json, path) ⇒ Object?
Fetch a node in given JSON
34 35 36 |
# File 'lib/kaze_client/json_utils.rb', line 34 def self.fetch_node(json, path) fetch_nodes(json, path).first end |
.fetch_nodes(json, path) ⇒ Array
Fetch nodes in given JSON
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kaze_client/json_utils.rb', line 16 def self.fetch_nodes(json, path) json = case json when ::KazeClient::Response json.parsed_response when String JSON.parse(json) else json end JsonPath.on(json, path) end |